[gnome-builder/wip/chergert/pipeline-merge: 51/64] flatpak: Make the flatpak manifest search recursive



commit 26b4be782798d976a4a3729b07a3d5ce6252e276
Author: Matthew Leeds <mleeds redhat com>
Date:   Fri Dec 23 19:18:56 2016 -0600

    flatpak: Make the flatpak manifest search recursive
    
    Some projects might want to put their flatpak manifest in a subdirectory
    rather than the project's root directory, and the performance hit seems
    negligible.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777959

 .../flatpak/gbp-flatpak-configuration-provider.c   |   55 ++++++++++++++------
 1 files changed, 39 insertions(+), 16 deletions(-)
---
diff --git a/plugins/flatpak/gbp-flatpak-configuration-provider.c 
b/plugins/flatpak/gbp-flatpak-configuration-provider.c
index 939c940..00edc4a 100644
--- a/plugins/flatpak/gbp-flatpak-configuration-provider.c
+++ b/plugins/flatpak/gbp-flatpak-configuration-provider.c
@@ -142,22 +142,14 @@ guess_primary_module (JsonNode *modules_node,
   return NULL;
 }
 
-static GPtrArray *
-gbp_flatpak_configuration_provider_find_flatpak_manifests (GbpFlatpakConfigurationProvider *self,
-                                                           GCancellable                    *cancellable,
-                                                           GFile                           *directory,
-                                                           GError                         **error)
+static gboolean
+check_dir_for_manifests (GFile         *directory,
+                         GPtrArray     *manifests,
+                         GCancellable  *cancellable,
+                         GError       **error)
 {
   g_autoptr(GFileEnumerator) enumerator = NULL;
   GFileInfo *file_info = NULL;
-  GPtrArray *ar;
-
-  g_assert (GBP_IS_FLATPAK_CONFIGURATION_PROVIDER (self));
-  g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
-  g_assert (G_IS_FILE (directory));
-
-  ar = g_ptr_array_new ();
-  g_ptr_array_set_free_func (ar, flatpak_manifest_free);
 
   enumerator = g_file_enumerate_children (directory,
                                           G_FILE_ATTRIBUTE_STANDARD_NAME,
@@ -165,7 +157,7 @@ gbp_flatpak_configuration_provider_find_flatpak_manifests (GbpFlatpakConfigurati
                                           cancellable,
                                           error);
   if (!enumerator)
-    return NULL;
+    return FALSE;
 
   while ((file_info = g_file_enumerator_next_file (enumerator, cancellable, NULL)))
     {
@@ -195,11 +187,18 @@ gbp_flatpak_configuration_provider_find_flatpak_manifests (GbpFlatpakConfigurati
       name = g_strdup (g_file_info_get_name (file_info));
       g_clear_object (&file_info);
 
-      if (name == NULL || file_type == G_FILE_TYPE_DIRECTORY)
+      if (name == NULL)
         continue;
 
       file = g_file_get_child (directory, name);
 
+      if (file_type == G_FILE_TYPE_DIRECTORY)
+        {
+          if (!check_dir_for_manifests (file, manifests, cancellable, error))
+            return FALSE;
+          continue;
+        }
+
       /* This regex is based on https://wiki.gnome.org/HowDoI/ChooseApplicationID */
       filename_regex = g_regex_new ("^[[:alnum:]-_]+\\.[[:alnum:]-_]+(\\.[[:alnum:]-_]+)*\\.json$",
                                     0, 0, NULL);
@@ -337,7 +336,31 @@ gbp_flatpak_configuration_provider_find_flatpak_manifests (GbpFlatpakConfigurati
             }
         }
 
-      g_ptr_array_add (ar, manifest);
+      g_ptr_array_add (manifests, manifest);
+    }
+
+  return TRUE;
+}
+
+static GPtrArray *
+gbp_flatpak_configuration_provider_find_flatpak_manifests (GbpFlatpakConfigurationProvider *self,
+                                                           GCancellable                    *cancellable,
+                                                           GFile                           *directory,
+                                                           GError                         **error)
+{
+  GPtrArray *ar;
+
+  g_assert (GBP_IS_FLATPAK_CONFIGURATION_PROVIDER (self));
+  g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+  g_assert (G_IS_FILE (directory));
+
+  ar = g_ptr_array_new ();
+  g_ptr_array_set_free_func (ar, flatpak_manifest_free);
+
+  if (!check_dir_for_manifests (directory, ar, cancellable, error))
+    {
+      g_ptr_array_free (ar, TRUE);
+      return NULL;
     }
 
   return ar;


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