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