From bdd317d999458fc35b23ee9c6141a9d0c9ec66f7 Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Fri, 24 Sep 2021 08:45:27 +0200 Subject: 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) -- cgit v1.2.1