[nautilus/wip/oholy/extraction-fixes: 12/16] file-operations: Remove leftover files after extraction failure
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/oholy/extraction-fixes: 12/16] file-operations: Remove leftover files after extraction failure
- Date: Mon, 25 Oct 2021 14:44:26 +0000 (UTC)
commit d09b34cde210c4f817d2442cc9378b1ddf73aee9
Author: Ondrej Holy <oholy redhat com>
Date: Fri Sep 24 08:40:23 2021 +0200
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]