From 53a449f84cdcb6c7c291ee659c62c96c4fcf88ac Mon Sep 17 00:00:00 2001 From: Michael Wehr Date: Mon, 10 Jan 2022 23:39:30 +0100 Subject: [PATCH] move total remaining time to global bar and fix format_time --- advcpmv-0.9-9.0.patch | 59 ++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/advcpmv-0.9-9.0.patch b/advcpmv-0.9-9.0.patch index 2b9369b..f02c22b 100644 --- a/advcpmv-0.9-9.0.patch +++ b/advcpmv-0.9-9.0.patch @@ -1,7 +1,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c --- coreutils-9.0/src/copy.c 2021-09-24 13:31:05.000000000 +0200 -+++ coreutils-9.0-patched/src/copy.c 2022-01-09 21:17:53.190781361 +0100 -@@ -129,6 +129,119 @@ ++++ coreutils-9.0-patched/src/copy.c 2022-01-10 23:37:17.800794586 +0100 +@@ -129,6 +129,122 @@ dev_t dev; }; @@ -50,7 +50,10 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c + size_t maxneeded = snprintf(NULL, 0, "%2dh %2dm %4.1fs", hr, min, sec) + 1; + char * _cTimeString; + _cTimeString = (char *) calloc( sizeof(char) * maxneeded, sizeof(char) ); -+ if ( seconds >= 3600 || showall) ++ if ( showall ) ++ { ++ sprintf(_cTimeString, "%2dh %2dm %2ds", hr, min, (int) sec); ++ } else if ( seconds >= 3600 ) + { + sprintf(_cTimeString, "%2dh %2dm %4.1fs", hr, min, sec); + } else if ( seconds >= 60 ) @@ -121,7 +124,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c /* Initial size of the cp.dest_info hash table. */ #define DEST_INFO_INITIAL_CAPACITY 61 -@@ -300,9 +413,16 @@ +@@ -300,9 +416,16 @@ static bool sparse_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, size_t hole_size, bool punch_holes, bool allow_reflink, @@ -139,7 +142,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c { *last_write_made_hole = false; *total_n_read = 0; -@@ -362,6 +482,81 @@ +@@ -362,6 +485,93 @@ while (max_n_read) { @@ -175,11 +178,23 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c + int sec_remaining = ( int ) ( ( double ) isec_elapsed / cur_size + * g_iTotalSize ) - isec_elapsed; + /* print out */ ++ ++ sprintf ( s_progress->cProgressField[1], ++ move_mode ++ ? "%d of %d files moved (about %s remaining) " ++ : "%d of %d files copied (about %s remaining) ", ++ g_iFilesCopied, g_iTotalFiles, format_time(sec_remaining, true) ); ++ ++ char s_ftime[100] = ""; ++ if (g_iTotalFiles > 1) ++ s_ftime[0] = '\0'; ++ else ++ sprintf ( s_ftime, "(about %s remaining)", format_time(sec_remaining, true) ); ++ + sprintf ( s_progress->cProgressField[3], + move_mode -+ ? "moving at %s/s (about %s remaining)" -+ : "copying at %s/s (about %s remaining)", s_copy_speed, -+ format_time(sec_remaining, true) ); ++ ? "moving at %s/s %s" ++ : "copying at %s/s %s", s_copy_speed, s_ftime ); + + int fs_len; + if ( g_iTotalFiles > 1 ) @@ -221,7 +236,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c ssize_t n_read = read (src_fd, buf, MIN (max_n_read, buf_size)); if (n_read < 0) { -@@ -446,6 +641,14 @@ +@@ -446,6 +656,14 @@ certain files in /proc or /sys with linux kernels. */ } @@ -236,7 +251,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c /* Ensure a trailing hole is created, so that subsequent calls of sparse_copy() start at the correct offset. */ if (make_hole && ! create_hole (dest_fd, dst_name, punch_holes, psize)) -@@ -517,8 +720,16 @@ +@@ -517,8 +735,16 @@ lseek_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, size_t hole_size, off_t ext_start, off_t src_total_size, enum Sparse_type sparse_mode, @@ -254,7 +269,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c { off_t last_ext_start = 0; off_t last_ext_len = 0; -@@ -590,10 +801,26 @@ +@@ -590,10 +816,26 @@ is conservative and may miss some holes. */ off_t n_read; bool read_hole; @@ -283,7 +298,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c return false; dest_pos = ext_start + n_read; -@@ -1374,8 +1601,84 @@ +@@ -1374,8 +1616,82 @@ buf_alloc = xmalloc (buf_size + buf_alignment); buf = ptr_align (buf_alloc, buf_alignment); @@ -323,12 +338,10 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c + + /* show how many files were written */ + int sum_length = 0; -+ if ( x->move_mode ) -+ sum_length = sprintf ( cProgressField[1], "%d of %d files moved so far...", -+ g_iFilesCopied, g_iTotalFiles ); -+ else -+ sum_length = sprintf ( cProgressField[1], "%d of %d files copied so far...", -+ g_iFilesCopied, g_iTotalFiles ); ++ sum_length = sprintf ( cProgressField[1], ++ x->move_mode ++ ? "%d of %d files moved so far" ++ : "%d of %d files copied so far", g_iFilesCopied, g_iTotalFiles ); + cProgressField[1][sum_length] = ' '; + } + @@ -368,7 +381,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c if (! ( #ifdef SEEK_HOLE scantype == LSEEK_SCANTYPE -@@ -1383,15 +1686,30 @@ +@@ -1383,15 +1699,30 @@ scan_inference.ext_start, src_open_sb.st_size, make_holes ? x->sparse_mode : SPARSE_NEVER, x->reflink_mode != REFLINK_NEVER, @@ -401,7 +414,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c { return_val = false; goto close_src_and_dst_desc; -@@ -1402,6 +1720,14 @@ +@@ -1402,6 +1733,14 @@ return_val = false; goto close_src_and_dst_desc; } @@ -418,7 +431,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c if (x->preserve_timestamps) diff -aur coreutils-9.0/src/copy.h coreutils-9.0-patched/src/copy.h --- coreutils-9.0/src/copy.h 2021-09-24 13:31:05.000000000 +0200 -+++ coreutils-9.0-patched/src/copy.h 2022-01-09 21:17:53.194781413 +0100 ++++ coreutils-9.0-patched/src/copy.h 2022-01-10 23:37:17.800794586 +0100 @@ -236,6 +236,11 @@ Create destination directories as usual. */ bool symbolic_link; @@ -453,7 +466,7 @@ diff -aur coreutils-9.0/src/copy.h coreutils-9.0-patched/src/copy.h #endif diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c --- coreutils-9.0/src/cp.c 2021-09-24 13:31:05.000000000 +0200 -+++ coreutils-9.0-patched/src/cp.c 2022-01-09 21:17:53.194781413 +0100 ++++ coreutils-9.0-patched/src/cp.c 2022-01-10 23:37:17.804794633 +0100 @@ -131,6 +131,9 @@ {"symbolic-link", no_argument, NULL, 's'}, {"target-directory", required_argument, NULL, 't'}, @@ -665,7 +678,7 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c version_control_string) diff -aur coreutils-9.0/src/mv.c coreutils-9.0-patched/src/mv.c --- coreutils-9.0/src/mv.c 2021-09-24 13:31:05.000000000 +0200 -+++ coreutils-9.0-patched/src/mv.c 2022-01-09 21:17:53.194781413 +0100 ++++ coreutils-9.0-patched/src/mv.c 2022-01-10 23:37:17.804794633 +0100 @@ -66,6 +66,9 @@ {"target-directory", required_argument, NULL, 't'}, {"update", no_argument, NULL, 'u'},