[gnome-builder/wip/cosimoc/flatpak-greeter: 6/9] Store strip_components centrally



commit 66840beef864e4317c553bfa84e0b4344b875b37
Author: Simon Schampijer <simon schampijer endlessm com>
Date:   Tue Dec 13 13:51:08 2016 +0100

    Store strip_components centrally

 plugins/flatpak/gbp-flatpak-clone-widget.c   |   10 +++++++++-
 plugins/flatpak/gbp-flatpak-source-archive.c |    7 ++++---
 plugins/flatpak/gbp-flatpak-source-archive.h |    1 +
 3 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/plugins/flatpak/gbp-flatpak-clone-widget.c b/plugins/flatpak/gbp-flatpak-clone-widget.c
index ff1b28b..233f576 100644
--- a/plugins/flatpak/gbp-flatpak-clone-widget.c
+++ b/plugins/flatpak/gbp-flatpak-clone-widget.c
@@ -38,6 +38,8 @@ struct _GbpFlatpakCloneWidget
   gchar          *child_name;
   gchar          *id;
   gchar          *manifest;
+
+  guint           strip_components;
 };
 
 typedef enum {
@@ -200,6 +202,7 @@ static void
 gbp_flatpak_clone_widget_init (GbpFlatpakCloneWidget *self)
 {
   gtk_widget_init_template (GTK_WIDGET (self));
+  self->strip_components = 1;
 }
 
 static void
@@ -355,7 +358,12 @@ gbp_flatpak_clone_widget_worker (GTask        *task,
   else if (req->src->type == TYPE_ARCHIVE)
     {
       uristr = ide_vcs_uri_to_string (req->src->uri);
-      req->project_file = fetch_archive (uristr, req->src->sha, req->src->name, req->destination, &error);
+      req->project_file = fetch_archive (uristr,
+                                         req->src->sha,
+                                         req->src->name,
+                                         req->destination,
+                                         self->strip_components,
+                                         &error);
     }
 
   /* copy manifest into the source directory */
diff --git a/plugins/flatpak/gbp-flatpak-source-archive.c b/plugins/flatpak/gbp-flatpak-source-archive.c
index 1fd4014..53d3bb7 100644
--- a/plugins/flatpak/gbp-flatpak-source-archive.c
+++ b/plugins/flatpak/gbp-flatpak-source-archive.c
@@ -353,7 +353,7 @@ strip_components_into (GFile   *dest,
 
 static GFile *
 create_uncompress_directory (GFile   *dest,
-                             int      strip_components,
+                             guint    strip_components,
                              GError **error)
 {
   GFile *uncompress_dest = NULL;
@@ -452,7 +452,7 @@ download_archive (SoupURI      *uri,
 static gboolean
 extract_archive (GFile   *destination,
                  GFile   *archive_file,
-                 int      strip_components,
+                 guint    strip_components,
                  GError **error)
 {
   ArchiveType type;
@@ -516,6 +516,7 @@ fetch_archive (const gchar  *url,
                const gchar  *sha,
                const gchar  *module_name,
                GFile        *destination,
+               guint         strip_components,
                GError      **error)
 {
   g_autoptr(GFile) archive_file = NULL;
@@ -543,7 +544,7 @@ fetch_archive (const gchar  *url,
   if (!download_archive (uri, sha, archive_file, error))
     return NULL;
 
-  if (!extract_archive (source_dir, archive_file, 1, error))
+  if (!extract_archive (source_dir, archive_file, strip_components, error))
     return NULL;
 
   return g_steal_pointer (&source_dir);
diff --git a/plugins/flatpak/gbp-flatpak-source-archive.h b/plugins/flatpak/gbp-flatpak-source-archive.h
index b8a0249..d662d94 100644
--- a/plugins/flatpak/gbp-flatpak-source-archive.h
+++ b/plugins/flatpak/gbp-flatpak-source-archive.h
@@ -23,6 +23,7 @@ GFile    *fetch_archive (const gchar  *url,
                          const gchar  *sha,
                          const gchar  *module_name,
                          GFile        *destination,
+                         guint         strip_components,
                          GError      **error);
 
 #endif /* GBP_FLATPAK_SOURCE_ARCHIVE_H */


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