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

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