[nautilus/wip/oholy/extraction-fixes: 1/4] file-operations: Simplify output files handling when extracting




commit c33bd12d6162b7fc7e7fd814820b72b3cc503ec8
Author: Ondrej Holy <oholy redhat com>
Date:   Fri Sep 24 08:45:27 2021 +0200

    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 c75f55d6e..fb5168c2e 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -8325,6 +8325,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;
 
@@ -8340,7 +8341,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);
@@ -8593,7 +8598,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;
@@ -8681,23 +8685,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)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]