[gnome-autoar/wip/oholy/extractor-one-file-same-name-fix: 1/4] extractor: Fix extraction of one file archives




commit 705c02ccfd9fb1dfbdd0c0aeca265cb9211ff08a
Author: Ondrej Holy <oholy redhat com>
Date:   Mon May 10 15:03:08 2021 +0200

    extractor: Fix extraction of one file archives
    
    Currently, an empty folder is created when extracting an archive over
    Nautilus which contains one file with the same name as the archive.
    This is because gnome-autoar always creates the top-level folder, but
    the one file archive with the same name should be extracted directly
    without creating additional folders. Otherwise the `conflict` signal
    is emitted and Nautilus by default skips conflicting files, so only
    empty folder remains after extraction. This problem have not been
    unfortunately noticed by the `test-one-file-same-name` unit test due to
    differences in the `decide-destination` signal handling. Let's do not
    create the top-level folder at all as `g_file_make_directory_with_parents`
    is used later anyway.
    
    Fixes: https://gitlab.gnome.org/GNOME/gnome-autoar/-/issues/28

 gnome-autoar/autoar-extractor.c | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)
---
diff --git a/gnome-autoar/autoar-extractor.c b/gnome-autoar/autoar-extractor.c
index eb707fe..0f4ad57 100644
--- a/gnome-autoar/autoar-extractor.c
+++ b/gnome-autoar/autoar-extractor.c
@@ -1832,28 +1832,11 @@ autoar_extractor_step_decide_destination (AutoarExtractor *self)
     }
   }
 
-  new_destination = (self->new_prefix != NULL) ? self->new_prefix : self->destination_dir;
-  destination_name = g_file_get_path (new_destination);
+  destination_name = g_file_get_path (self->new_prefix != NULL ?
+                                      self->new_prefix :
+                                      self->new_destination);
   g_debug ("autoar_extractor_step_decide_destination: destination %s", destination_name);
 
-  g_file_make_directory_with_parents (new_destination,
-                                      self->cancellable,
-                                      &(self->error));
-
-  if (g_error_matches (self->error, G_IO_ERROR, G_IO_ERROR_EXISTS)) {
-    GFileType file_type;
-
-    file_type = g_file_query_file_type (new_destination,
-                                        G_FILE_QUERY_INFO_NONE,
-                                        NULL);
-
-    if (file_type == G_FILE_TYPE_DIRECTORY) {
-      /* FIXME: Implement a way to solve directory conflicts */
-      g_debug ("autoar_extractor_step_decide_destination: destination directory exists");
-      g_clear_error (&self->error);
-    }
-  }
-
   g_list_free_full (files, g_object_unref);
 }
 


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