[patch] Fix progress reporting for file move



Hello

If a file is moved by copy/remove the progress bar is advanced twice. On
the other hand, if a file is moved by renaming the progress bar is never
updated. The attached patch fixes this.

cheers,
Hampa

diff -ur mc-cvs/src/file.c mc-dev/src/file.c
--- mc-cvs/src/file.c	2006-04-25 05:05:17.000000000 +0200
+++ mc-dev/src/file.c	2006-05-03 07:09:36.000000000 +0200
@@ -1022,6 +1022,7 @@
 {
     struct stat src_stats, dst_stats;
     int return_status = FILE_CONT;
+    int copy = 0;
 
     if (file_progress_show_source (ctx, s) == FILE_ABORT
 	|| file_progress_show_target (ctx, d) == FILE_ABORT)
@@ -1080,7 +1081,9 @@
 	}
 
 	if (mc_rename (s, d) == 0) {
-	    return FILE_CONT;
+	    return progress_update_one (ctx, progress_count,
+	    				progress_bytes,
+	    				src_stats.st_size, 1);
 	}
     }
 #if 0
@@ -1107,6 +1110,8 @@
     if (return_status != FILE_CONT)
 	return return_status;
 
+    copy = 1;
+
     if ((return_status =
 	 file_progress_show_source (ctx, NULL)) != FILE_CONT
 	|| (return_status = file_progress_show (ctx, 0, 0)) != FILE_CONT)
@@ -1123,11 +1128,12 @@
 	return return_status;
     }
 
-    if (return_status == FILE_CONT)
+    if (copy == 0) {
 	return_status = progress_update_one (ctx,
 					     progress_count,
 					     progress_bytes,
 					     src_stats.st_size, 1);
+    }
 
     return return_status;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]