diff --git a/builder/builder-cache.c b/builder/builder-cache.c index d9080ad0..b2551cd5 100644 --- a/builder/builder-cache.c +++ b/builder/builder-cache.c @@ -34,12 +34,13 @@ #include "flatpak-utils.h" #include "builder-utils.h" #include "builder-cache.h" +#include "builder-context.h" struct BuilderCache { GObject parent; + BuilderContext *context; GChecksum *checksum; - GFile *cache_dir; GFile *app_dir; char *branch; char *stage; @@ -58,7 +59,7 @@ G_DEFINE_TYPE (BuilderCache, builder_cache, G_TYPE_OBJECT); enum { PROP_0, - PROP_CACHE_DIR, + PROP_CONTEXT, PROP_APP_DIR, PROP_BRANCH, LAST_PROP @@ -72,7 +73,7 @@ builder_cache_finalize (GObject *object) { BuilderCache *self = (BuilderCache *) object; - g_clear_object (&self->cache_dir); + g_clear_object (&self->context); g_clear_object (&self->app_dir); g_clear_object (&self->repo); g_checksum_free (self->checksum); @@ -95,8 +96,8 @@ builder_cache_get_property (GObject *object, switch (prop_id) { - case PROP_CACHE_DIR: - g_value_set_object (value, self->cache_dir); + case PROP_CONTEXT: + g_value_set_object (value, self->context); break; case PROP_APP_DIR: @@ -127,8 +128,8 @@ builder_cache_set_property (GObject *object, self->branch = g_value_dup_string (value); break; - case PROP_CACHE_DIR: - g_set_object (&self->cache_dir, g_value_get_object (value)); + case PROP_CONTEXT: + g_set_object (&self->context, g_value_get_object (value)); break; case PROP_APP_DIR: @@ -150,11 +151,11 @@ builder_cache_class_init (BuilderCacheClass *klass) object_class->set_property = builder_cache_set_property; g_object_class_install_property (object_class, - PROP_CACHE_DIR, - g_param_spec_object ("cache-dir", + PROP_CONTEXT, + g_param_spec_object ("context", "", "", - G_TYPE_FILE, + BUILDER_TYPE_CONTEXT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); g_object_class_install_property (object_class, PROP_APP_DIR, @@ -179,12 +180,12 @@ builder_cache_init (BuilderCache *self) } BuilderCache * -builder_cache_new (GFile *cache_dir, +builder_cache_new (BuilderContext *context, GFile *app_dir, const char *branch) { return g_object_new (BUILDER_TYPE_CACHE, - "cache-dir", cache_dir, + "context", context, "app-dir", app_dir, "branch", branch, NULL); @@ -222,15 +223,15 @@ gboolean builder_cache_open (BuilderCache *self, GError **error) { - self->repo = ostree_repo_new (self->cache_dir); + self->repo = ostree_repo_new (builder_context_get_cache_dir (self->context)); /* We don't need fsync on checkouts as they are transient, and we rely on the syncfs() in the transaction commit for commits. */ ostree_repo_set_disable_fsync (self->repo, TRUE); - if (!g_file_query_exists (self->cache_dir, NULL)) + if (!g_file_query_exists (builder_context_get_cache_dir (self->context), NULL)) { - g_autoptr(GFile) parent = g_file_get_parent (self->cache_dir); + g_autoptr(GFile) parent = g_file_get_parent (builder_context_get_cache_dir (self->context)); if (!flatpak_mkdir_p (parent, NULL, error)) return FALSE; diff --git a/builder/builder-cache.h b/builder/builder-cache.h index 50b81cb4..54589b57 100644 --- a/builder/builder-cache.h +++ b/builder/builder-cache.h @@ -27,6 +27,7 @@ G_BEGIN_DECLS typedef struct BuilderCache BuilderCache; +typedef struct BuilderContext BuilderContext; #define BUILDER_TYPE_CACHE (builder_cache_get_type ()) #define BUILDER_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BUILDER_TYPE_CACHE, BuilderCache)) @@ -34,7 +35,7 @@ typedef struct BuilderCache BuilderCache; GType builder_cache_get_type (void); -BuilderCache *builder_cache_new (GFile *cache_dir, +BuilderCache *builder_cache_new (BuilderContext *context, GFile *app_dir, const char *branch); void builder_cache_disable_lookups (BuilderCache *self); diff --git a/builder/builder-context.c b/builder/builder-context.c index fb669899..c08bf8a4 100644 --- a/builder/builder-context.c +++ b/builder/builder-context.c @@ -30,6 +30,7 @@ #include "flatpak-utils.h" #include "builder-context.h" +#include "builder-cache.h" struct BuilderContext { diff --git a/builder/builder-context.h b/builder/builder-context.h index 29817b1e..8de9cd7c 100644 --- a/builder/builder-context.h +++ b/builder/builder-context.h @@ -27,7 +27,7 @@ G_BEGIN_DECLS -/* BuilderContext defined in builder-options.h to fix include loop */ +/* BuilderContext defined in builder-cache.h to fix include loop */ #define BUILDER_TYPE_CONTEXT (builder_context_get_type ()) #define BUILDER_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BUILDER_TYPE_CONTEXT, BuilderContext)) diff --git a/builder/builder-main.c b/builder/builder-main.c index 2db23313..68fadd01 100644 --- a/builder/builder-main.c +++ b/builder/builder-main.c @@ -412,7 +412,7 @@ main (int argc, cache_branch = g_path_get_basename (manifest_path); - cache = builder_cache_new (builder_context_get_cache_dir (build_context), app_dir, cache_branch); + cache = builder_cache_new (build_context, app_dir, cache_branch); if (!builder_cache_open (cache, &error)) { g_printerr ("Error opening cache: %s\n", error->message); diff --git a/builder/builder-options.h b/builder/builder-options.h index 048d65e8..6089c205 100644 --- a/builder/builder-options.h +++ b/builder/builder-options.h @@ -26,7 +26,6 @@ G_BEGIN_DECLS -typedef struct BuilderContext BuilderContext; typedef struct BuilderOptions BuilderOptions; #define BUILDER_TYPE_OPTIONS (builder_options_get_type ())