Backport various upstream fixes for archive extraction
Resolves: #1995615
This commit is contained in:
parent
72fbf82883
commit
788b75c359
113
file-operations-Do-not-offer-skipping-when-extractin.patch
Normal file
113
file-operations-Do-not-offer-skipping-when-extractin.patch
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
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
|
||||||
|
|
113
file-operations-Fix-progress-when-skipping-during-ex.patch
Normal file
113
file-operations-Fix-progress-when-skipping-during-ex.patch
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
From c3b8e0d6dee8ae8d86cbc47a0745b3e9b2b814e7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Ondrej Holy <oholy@redhat.com>
|
||||||
|
Date: Fri, 24 Sep 2021 09:56:07 +0200
|
||||||
|
Subject: [PATCH] file-operations: Fix progress when skipping during extraction
|
||||||
|
|
||||||
|
The progress is wrong when extracting multiple files and some of them
|
||||||
|
are skipped. Let's try to fix this.
|
||||||
|
---
|
||||||
|
src/nautilus-file-operations.c | 35 ++++++++++++++++++++++++++--------
|
||||||
|
1 file changed, 27 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
|
||||||
|
index c95748ccc..5fc8af2f3 100644
|
||||||
|
--- a/src/nautilus-file-operations.c
|
||||||
|
+++ b/src/nautilus-file-operations.c
|
||||||
|
@@ -205,6 +205,7 @@ typedef struct
|
||||||
|
GFile *destination_directory;
|
||||||
|
GList *output_files;
|
||||||
|
gboolean destination_decided;
|
||||||
|
+ gboolean extraction_failed;
|
||||||
|
|
||||||
|
gdouble base_progress;
|
||||||
|
|
||||||
|
@@ -8346,6 +8347,8 @@ extract_job_on_error (AutoarExtractor *extractor,
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ extract_job->extraction_failed = TRUE;
|
||||||
|
+
|
||||||
|
/* It is safe to use extract_job->output_files->data only when the
|
||||||
|
* extract_job->destination_decided variable was set, see comment in the
|
||||||
|
* extract_job_on_decide_destination function.
|
||||||
|
@@ -8571,8 +8574,7 @@ extract_job_on_scanned (AutoarExtractor *extractor,
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
-report_extract_final_progress (ExtractJob *extract_job,
|
||||||
|
- gint total_files)
|
||||||
|
+report_extract_final_progress (ExtractJob *extract_job)
|
||||||
|
{
|
||||||
|
char *status;
|
||||||
|
g_autofree gchar *basename_dest = NULL;
|
||||||
|
@@ -8582,7 +8584,11 @@ report_extract_final_progress (ExtractJob *extract_job,
|
||||||
|
extract_job->destination_directory);
|
||||||
|
basename_dest = get_basename (extract_job->destination_directory);
|
||||||
|
|
||||||
|
- if (total_files == 1)
|
||||||
|
+ /* The g_list_length function is used intentionally here instead of the
|
||||||
|
+ * extract_job->total_files variable to avoid printing wrong basename in
|
||||||
|
+ * the case of skipped files.
|
||||||
|
+ */
|
||||||
|
+ if (g_list_length (extract_job->source_files) == 1)
|
||||||
|
{
|
||||||
|
GFile *source_file;
|
||||||
|
g_autofree gchar *basename = NULL;
|
||||||
|
@@ -8597,8 +8603,8 @@ report_extract_final_progress (ExtractJob *extract_job,
|
||||||
|
{
|
||||||
|
status = g_strdup_printf (ngettext ("Extracted %'d file to “%s”",
|
||||||
|
"Extracted %'d files to “%s”",
|
||||||
|
- total_files),
|
||||||
|
- total_files,
|
||||||
|
+ extract_job->total_files),
|
||||||
|
+ extract_job->total_files,
|
||||||
|
basename_dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -8609,6 +8615,8 @@ report_extract_final_progress (ExtractJob *extract_job,
|
||||||
|
g_strdup_printf (_("%s / %s"),
|
||||||
|
formatted_size,
|
||||||
|
formatted_size));
|
||||||
|
+
|
||||||
|
+ nautilus_progress_info_set_progress (extract_job->common.progress, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
@@ -8690,6 +8698,7 @@ extract_task_thread_func (GTask *task,
|
||||||
|
|
||||||
|
extract_job->archive_compressed_size = archive_compressed_sizes[i];
|
||||||
|
extract_job->destination_decided = FALSE;
|
||||||
|
+ extract_job->extraction_failed = FALSE;
|
||||||
|
|
||||||
|
autoar_extractor_start (extractor,
|
||||||
|
extract_job->common.cancellable);
|
||||||
|
@@ -8697,13 +8706,23 @@ extract_task_thread_func (GTask *task,
|
||||||
|
g_signal_handlers_disconnect_by_data (extractor,
|
||||||
|
extract_job);
|
||||||
|
|
||||||
|
- extract_job->base_progress += (gdouble) extract_job->archive_compressed_size /
|
||||||
|
- (gdouble) extract_job->total_compressed_size;
|
||||||
|
+ if (!extract_job->extraction_failed)
|
||||||
|
+ {
|
||||||
|
+ extract_job->base_progress += (gdouble) extract_job->archive_compressed_size /
|
||||||
|
+ (gdouble) extract_job->total_compressed_size;
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ extract_job->total_files--;
|
||||||
|
+ extract_job->base_progress *= extract_job->total_compressed_size;
|
||||||
|
+ extract_job->total_compressed_size -= extract_job->archive_compressed_size;
|
||||||
|
+ extract_job->base_progress /= extract_job->total_compressed_size;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!job_aborted ((CommonJob *) extract_job))
|
||||||
|
{
|
||||||
|
- report_extract_final_progress (extract_job, extract_job->total_files);
|
||||||
|
+ report_extract_final_progress (extract_job);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extract_job->common.undo_info)
|
||||||
|
--
|
||||||
|
2.33.1
|
||||||
|
|
70
file-operations-Remove-leftover-files-after-extracti.patch
Normal file
70
file-operations-Remove-leftover-files-after-extracti.patch
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
From d09b34cde210c4f817d2442cc9378b1ddf73aee9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Ondrej Holy <oholy@redhat.com>
|
||||||
|
Date: Fri, 24 Sep 2021 08:40:23 +0200
|
||||||
|
Subject: [PATCH] file-operations: Remove leftover files after extraction
|
||||||
|
failure
|
||||||
|
|
||||||
|
Empty, or corrupted files are left in the output directory in the case
|
||||||
|
of extraction failure, e.g. when wrong password is supplied. This is
|
||||||
|
in most cases undesired. Let's recursively delete all the leftover
|
||||||
|
files in the case of extraction failure.
|
||||||
|
|
||||||
|
Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/1954
|
||||||
|
---
|
||||||
|
src/nautilus-file-operations.c | 17 +++++++++++++++++
|
||||||
|
1 file changed, 17 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
|
||||||
|
index 7927bd504..13da2cb39 100644
|
||||||
|
--- a/src/nautilus-file-operations.c
|
||||||
|
+++ b/src/nautilus-file-operations.c
|
||||||
|
@@ -204,6 +204,7 @@ typedef struct
|
||||||
|
GList *source_files;
|
||||||
|
GFile *destination_directory;
|
||||||
|
GList *output_files;
|
||||||
|
+ gboolean destination_decided;
|
||||||
|
|
||||||
|
gdouble base_progress;
|
||||||
|
|
||||||
|
@@ -8202,8 +8203,14 @@ extract_job_on_decide_destination (AutoarExtractor *extractor,
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /* The extract_job->destination_decided variable signalizes whether the
|
||||||
|
+ * extract_job->output_files list already contains the final location as
|
||||||
|
+ * its first link. There is no way to get this over the AutoarExtractor
|
||||||
|
+ * API currently.
|
||||||
|
+ */
|
||||||
|
extract_job->output_files = g_list_prepend (extract_job->output_files,
|
||||||
|
decided_destination);
|
||||||
|
+ extract_job->destination_decided = TRUE;
|
||||||
|
|
||||||
|
return g_object_ref (decided_destination);
|
||||||
|
}
|
||||||
|
@@ -8336,6 +8343,15 @@ extract_job_on_error (AutoarExtractor *extractor,
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /* It is safe to use extract_job->output_files->data only when the
|
||||||
|
+ * extract_job->destination_decided variable was set, see comment in the
|
||||||
|
+ * extract_job_on_decide_destination function.
|
||||||
|
+ */
|
||||||
|
+ if (extract_job->destination_decided)
|
||||||
|
+ {
|
||||||
|
+ delete_file_recursively (extract_job->output_files->data, NULL, NULL, NULL);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
basename = get_basename (source_file);
|
||||||
|
nautilus_progress_info_take_status (extract_job->common.progress,
|
||||||
|
g_strdup_printf (_("Error extracting “%s”"),
|
||||||
|
@@ -8657,6 +8673,7 @@ extract_task_thread_func (GTask *task,
|
||||||
|
extract_job);
|
||||||
|
|
||||||
|
extract_job->archive_compressed_size = archive_compressed_sizes[i];
|
||||||
|
+ extract_job->destination_decided = FALSE;
|
||||||
|
|
||||||
|
autoar_extractor_start (extractor,
|
||||||
|
extract_job->common.cancellable);
|
||||||
|
--
|
||||||
|
2.33.1
|
||||||
|
|
74
file-operations-Simplify-output-files-handling-when-.patch
Normal file
74
file-operations-Simplify-output-files-handling-when-.patch
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
From bdd317d999458fc35b23ee9c6141a9d0c9ec66f7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Ondrej Holy <oholy@redhat.com>
|
||||||
|
Date: Fri, 24 Sep 2021 08:45:27 +0200
|
||||||
|
Subject: [PATCH] file-operations: Simplify output files handling when
|
||||||
|
extracting
|
||||||
|
|
||||||
|
Currently, output files are checked for existence. But the files are
|
||||||
|
explicitely deleted in the case of extraction failure, so this extra
|
||||||
|
check is no more needed. Let's drop the redundant check and just update
|
||||||
|
the list when deleting the files.
|
||||||
|
---
|
||||||
|
src/nautilus-file-operations.c | 25 ++++++-------------------
|
||||||
|
1 file changed, 6 insertions(+), 19 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
|
||||||
|
index 13da2cb39..14dcf64d0 100644
|
||||||
|
--- a/src/nautilus-file-operations.c
|
||||||
|
+++ b/src/nautilus-file-operations.c
|
||||||
|
@@ -8330,6 +8330,7 @@ extract_job_on_error (AutoarExtractor *extractor,
|
||||||
|
{
|
||||||
|
ExtractJob *extract_job = user_data;
|
||||||
|
GFile *source_file;
|
||||||
|
+ GFile *destination;
|
||||||
|
gint response_id;
|
||||||
|
g_autofree gchar *basename = NULL;
|
||||||
|
|
||||||
|
@@ -8349,7 +8350,11 @@ extract_job_on_error (AutoarExtractor *extractor,
|
||||||
|
*/
|
||||||
|
if (extract_job->destination_decided)
|
||||||
|
{
|
||||||
|
- delete_file_recursively (extract_job->output_files->data, NULL, NULL, NULL);
|
||||||
|
+ destination = extract_job->output_files->data;
|
||||||
|
+ delete_file_recursively (destination, NULL, NULL, NULL);
|
||||||
|
+ extract_job->output_files = g_list_delete_link (extract_job->output_files,
|
||||||
|
+ extract_job->output_files);
|
||||||
|
+ g_object_unref (destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
basename = get_basename (source_file);
|
||||||
|
@@ -8602,7 +8607,6 @@ extract_task_thread_func (GTask *task,
|
||||||
|
{
|
||||||
|
ExtractJob *extract_job = task_data;
|
||||||
|
GList *l;
|
||||||
|
- GList *existing_output_files = NULL;
|
||||||
|
gint total_files;
|
||||||
|
g_autofree guint64 *archive_compressed_sizes = NULL;
|
||||||
|
gint i;
|
||||||
|
@@ -8690,23 +8694,6 @@ extract_task_thread_func (GTask *task,
|
||||||
|
report_extract_final_progress (extract_job, total_files);
|
||||||
|
}
|
||||||
|
|
||||||
|
- for (l = extract_job->output_files; l != NULL; l = l->next)
|
||||||
|
- {
|
||||||
|
- GFile *output_file;
|
||||||
|
-
|
||||||
|
- output_file = G_FILE (l->data);
|
||||||
|
-
|
||||||
|
- if (g_file_query_exists (output_file, NULL))
|
||||||
|
- {
|
||||||
|
- existing_output_files = g_list_prepend (existing_output_files,
|
||||||
|
- g_object_ref (output_file));
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- g_list_free_full (extract_job->output_files, g_object_unref);
|
||||||
|
-
|
||||||
|
- extract_job->output_files = existing_output_files;
|
||||||
|
-
|
||||||
|
if (extract_job->common.undo_info)
|
||||||
|
{
|
||||||
|
if (extract_job->output_files)
|
||||||
|
--
|
||||||
|
2.33.1
|
||||||
|
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
Name: nautilus
|
Name: nautilus
|
||||||
Version: 40.2
|
Version: 40.2
|
||||||
Release: 3%{?dist}
|
Release: 4%{?dist}
|
||||||
Summary: File manager for GNOME
|
Summary: File manager for GNOME
|
||||||
|
|
||||||
License: GPLv3+
|
License: GPLv3+
|
||||||
@ -18,6 +18,12 @@ Patch1: compress-dialog-Update-dialog-design.patch
|
|||||||
Patch2: compress-dialog-Add-support-for-encrypted-.zip.patch
|
Patch2: compress-dialog-Add-support-for-encrypted-.zip.patch
|
||||||
Patch3: compress-dialog-Backport-translations.patch
|
Patch3: compress-dialog-Backport-translations.patch
|
||||||
|
|
||||||
|
# https://gitlab.gnome.org/GNOME/nautilus/-/issues/1954
|
||||||
|
Patch4: file-operations-Remove-leftover-files-after-extracti.patch
|
||||||
|
Patch5: file-operations-Simplify-output-files-handling-when-.patch
|
||||||
|
Patch6: file-operations-Do-not-offer-skipping-when-extractin.patch
|
||||||
|
Patch7: file-operations-Fix-progress-when-skipping-during-ex.patch
|
||||||
|
|
||||||
BuildRequires: desktop-file-utils
|
BuildRequires: desktop-file-utils
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
BuildRequires: gettext
|
BuildRequires: gettext
|
||||||
@ -148,6 +154,9 @@ desktop-file-validate $RPM_BUILD_ROOT%{_datadir}/applications/*.desktop
|
|||||||
%doc %{_datadir}/gtk-doc/html/libnautilus-extension/
|
%doc %{_datadir}/gtk-doc/html/libnautilus-extension/
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Dec 08 2021 Ondrej Holy <oholy@redhat.com> - 40.2-4
|
||||||
|
- Backport various upstream fixes for archive extraction (#1995615)
|
||||||
|
|
||||||
* Fri Sep 17 2021 Ondrej Holy <oholy@redhat.com> - 40.2-3
|
* Fri Sep 17 2021 Ondrej Holy <oholy@redhat.com> - 40.2-3
|
||||||
- Backport translations for encrypted archives support (#2003134)
|
- Backport translations for encrypted archives support (#2003134)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user