[nautilus] file-operations: Fix directory "skipped" flag



commit 33debe4f247fae4afaec14a95ab92119aad3c697
Author: Sachin Daluja <30343-sachindaluja users noreply gitlab gnome org>
Date:   Sat Dec 5 13:30:36 2020 -0500

    file-operations: Fix directory "skipped" flag
    
    During a "merge" directory copy operation, when recursively merging
    a directory to a destination directory that already contains some files
    or subdirectories that are being copied, the "skip" flag is set
    individually for those files or subdirectories. This correctly reduces
    the count total files being copied for each file or subdirectory that
    was skipped.
    
    However, the "skipped" flag was then also being set for the parent
    directory even though that directory was successfully copied (when
    represented as a single file which is also included in the file count).
    This ended up incorrectly reducing the total file count even though
    the copied file count was incremented for that directory.
    
    Change code to ensure that the "skipped" flag is not set for a
    directory when one or more children are skipped.

 src/nautilus-file-operations.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
---
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
index c007f7625..3bd7d55aa 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -4776,6 +4776,7 @@ copy_move_directory (CopyMoveJob   *copy_job,
     GFileCopyFlags flags;
 
     job = (CommonJob *) copy_job;
+    *skipped_file = FALSE;
 
     if (create_dest)
     {
@@ -4979,7 +4980,7 @@ retry:
         else if (response == 1)
         {
             /* Skip: Do Nothing  */
-            local_skipped_file = TRUE;
+            *skipped_file = TRUE;
         }
         else if (response == 2)
         {
@@ -5003,6 +5004,7 @@ retry:
 
     if (!job_aborted (job) && copy_job->is_move &&
         /* Don't delete source if there was a skipped file */
+        !*skipped_file &&
         !local_skipped_file)
     {
         if (!g_file_delete (src, job->cancellable, &error))
@@ -5011,7 +5013,7 @@ retry:
 
             if (job->skip_all_error)
             {
-                local_skipped_file = TRUE;
+                *skipped_file = TRUE;
                 goto skip;
             }
             basename = get_basename (src);
@@ -5033,11 +5035,11 @@ retry:
             else if (response == 1)                 /* skip all */
             {
                 job->skip_all_error = TRUE;
-                local_skipped_file = TRUE;
+                *skipped_file = TRUE;
             }
             else if (response == 2)                 /* skip */
             {
-                local_skipped_file = TRUE;
+                *skipped_file = TRUE;
             }
             else
             {
@@ -5049,11 +5051,6 @@ skip:
         }
     }
 
-    if (local_skipped_file)
-    {
-        *skipped_file = TRUE;
-    }
-
     g_free (dest_fs_type);
     return TRUE;
 }


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