Blame SOURCES/file-operations-Do-not-offer-skipping-when-extractin.patch

6a4a9c
From d4e00000d46e0407841424a478eab833cf59cc12 Mon Sep 17 00:00:00 2001
6a4a9c
From: Ondrej Holy <oholy@redhat.com>
6a4a9c
Date: Fri, 24 Sep 2021 09:42:54 +0200
6a4a9c
Subject: [PATCH] file-operations: Do not offer skipping when extracting one
6a4a9c
 file
6a4a9c
6a4a9c
In case of extraction failure, the "Skip" and "Cancel" actions are offered
6a4a9c
everytime, but skipping doesn't make sense when extracting one file only.
6a4a9c
Let's use the same approach as it is used also for other operations, which
6a4a9c
is based on total number of files and remaining files. Also the "Skip All"
6a4a9c
action will be offered as a side-effect of this change.
6a4a9c
---
6a4a9c
 src/nautilus-file-operations.c | 38 ++++++++++++++++++++++------------
6a4a9c
 1 file changed, 25 insertions(+), 13 deletions(-)
6a4a9c
6a4a9c
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
6a4a9c
index 14dcf64d0..c95748ccc 100644
6a4a9c
--- a/src/nautilus-file-operations.c
6a4a9c
+++ b/src/nautilus-file-operations.c
6a4a9c
@@ -210,6 +210,7 @@ typedef struct
6a4a9c
 
6a4a9c
     guint64 archive_compressed_size;
6a4a9c
     guint64 total_compressed_size;
6a4a9c
+    gint total_files;
6a4a9c
 
6a4a9c
     NautilusExtractCallback done_callback;
6a4a9c
     gpointer done_callback_data;
6a4a9c
@@ -8332,6 +8333,7 @@ extract_job_on_error (AutoarExtractor *extractor,
6a4a9c
     GFile *source_file;
6a4a9c
     GFile *destination;
6a4a9c
     gint response_id;
6a4a9c
+    gint remaining_files;
6a4a9c
     g_autofree gchar *basename = NULL;
6a4a9c
 
6a4a9c
     source_file = autoar_extractor_get_source_file (extractor);
6a4a9c
@@ -8357,25 +8359,35 @@ extract_job_on_error (AutoarExtractor *extractor,
6a4a9c
         g_object_unref (destination);
6a4a9c
     }
6a4a9c
 
6a4a9c
+    if (extract_job->common.skip_all_error)
6a4a9c
+    {
6a4a9c
+        return;
6a4a9c
+    }
6a4a9c
+
6a4a9c
     basename = get_basename (source_file);
6a4a9c
     nautilus_progress_info_take_status (extract_job->common.progress,
6a4a9c
                                         g_strdup_printf (_("Error extracting “%s”"),
6a4a9c
                                                          basename));
6a4a9c
 
6a4a9c
-    response_id = run_warning ((CommonJob *) extract_job,
6a4a9c
-                               g_strdup_printf (_("There was an error while extracting “%s”."),
6a4a9c
-                                                basename),
6a4a9c
-                               g_strdup (error->message),
6a4a9c
-                               NULL,
6a4a9c
-                               FALSE,
6a4a9c
-                               CANCEL,
6a4a9c
-                               SKIP,
6a4a9c
-                               NULL);
6a4a9c
+    remaining_files = g_list_length (g_list_find_custom (extract_job->source_files,
6a4a9c
+                                                         source_file,
6a4a9c
+                                                         (GCompareFunc) g_file_equal)) - 1;
6a4a9c
+    response_id = run_cancel_or_skip_warning ((CommonJob *) extract_job,
6a4a9c
+                                              g_strdup_printf (_("There was an error while extracting “%s”."),
6a4a9c
+                                                               basename),
6a4a9c
+                                              g_strdup (error->message),
6a4a9c
+                                              NULL,
6a4a9c
+                                              extract_job->total_files,
6a4a9c
+                                              remaining_files);
6a4a9c
 
6a4a9c
     if (response_id == 0 || response_id == GTK_RESPONSE_DELETE_EVENT)
6a4a9c
     {
6a4a9c
         abort_job ((CommonJob *) extract_job);
6a4a9c
     }
6a4a9c
+    else if (response_id == 1)
6a4a9c
+    {
6a4a9c
+        extract_job->common.skip_all_error = TRUE;
6a4a9c
+    }
6a4a9c
 }
6a4a9c
 
6a4a9c
 static void
6a4a9c
@@ -8607,7 +8619,6 @@ extract_task_thread_func (GTask        *task,
6a4a9c
 {
6a4a9c
     ExtractJob *extract_job = task_data;
6a4a9c
     GList *l;
6a4a9c
-    gint total_files;
6a4a9c
     g_autofree guint64 *archive_compressed_sizes = NULL;
6a4a9c
     gint i;
6a4a9c
 
6a4a9c
@@ -8618,9 +8629,10 @@ extract_task_thread_func (GTask        *task,
6a4a9c
     nautilus_progress_info_set_details (extract_job->common.progress,
6a4a9c
                                         _("Preparing to extract"));
6a4a9c
 
6a4a9c
-    total_files = g_list_length (extract_job->source_files);
6a4a9c
+    extract_job->total_files = g_list_length (extract_job->source_files);
6a4a9c
 
6a4a9c
-    archive_compressed_sizes = g_malloc0_n (total_files, sizeof (guint64));
6a4a9c
+    archive_compressed_sizes = g_malloc0_n (extract_job->total_files,
6a4a9c
+                                            sizeof (guint64));
6a4a9c
     extract_job->total_compressed_size = 0;
6a4a9c
 
6a4a9c
     for (l = extract_job->source_files, i = 0;
6a4a9c
@@ -8691,7 +8703,7 @@ extract_task_thread_func (GTask        *task,
6a4a9c
 
6a4a9c
     if (!job_aborted ((CommonJob *) extract_job))
6a4a9c
     {
6a4a9c
-        report_extract_final_progress (extract_job, total_files);
6a4a9c
+        report_extract_final_progress (extract_job, extract_job->total_files);
6a4a9c
     }
6a4a9c
 
6a4a9c
     if (extract_job->common.undo_info)
6a4a9c
-- 
6a4a9c
2.33.1
6a4a9c