[gnome-autoar/wip/oholy/various-fixes: 7/23] extractor: Do not allow prefix modifications when output-is-dest




commit 9ba3d2da6818ccab92197a66a5356daa23c1604d
Author: Ondrej Holy <oholy redhat com>
Date:   Tue Feb 23 13:00:27 2021 +0100

    extractor: Do not allow prefix modifications when output-is-dest
    
    If the `output-is-dest` property is `TRUE`, the `prefix` is not cleared and is
    passed to `decide-destination` signal. This looks unexpected because it allows
    to change even the prefix which doesn't match archive name, which is not allowed
    even if `output-is-dest` is `FALSE`. I am conviced that it should not be allowed
    to change the `prefix` at all in this case. Let's clear the `prefix` variable to
    avoid that.

 gnome-autoar/autoar-extractor.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
---
diff --git a/gnome-autoar/autoar-extractor.c b/gnome-autoar/autoar-extractor.c
index 44966e6..9ec16d3 100644
--- a/gnome-autoar/autoar-extractor.c
+++ b/gnome-autoar/autoar-extractor.c
@@ -1768,18 +1768,6 @@ autoar_extractor_step_scan_toplevel (AutoarExtractor *self)
 
   self->files_list = g_list_reverse (self->files_list);
 
-  self->prefix =
-    autoar_extractor_get_common_prefix (self->files_list,
-                                        self->output_file);
-
-  if (self->prefix != NULL) {
-    g_autofree char *path_prefix;
-
-    path_prefix = g_file_get_path (self->prefix);
-    g_debug ("autoar_extractor_step_scan_toplevel: pathname_prefix = %s",
-             path_prefix);
-  }
-
   autoar_extractor_signal_scanned (self);
 }
 
@@ -1795,6 +1783,8 @@ autoar_extractor_step_set_destination (AutoarExtractor *self)
     return;
   }
 
+  self->prefix = autoar_extractor_get_common_prefix (self->files_list,
+                                                     self->output_file);
   if (self->prefix != NULL) {
     /* We must check if the archive and the prefix have the same name (without
      * the extension). If they do, then the destination should be the output
@@ -1803,6 +1793,9 @@ autoar_extractor_step_set_destination (AutoarExtractor *self)
     g_autofree char *prefix_name;
     g_autofree char *prefix_name_no_ext;
 
+    g_debug ("autoar_extractor_step_set_destination: pathname_prefix = %s",
+             g_file_peek_path (self->prefix));
+
     prefix_name = g_file_get_basename (self->prefix);
     prefix_name_no_ext = autoar_common_get_basename_remove_extension (prefix_name);
 


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