Skip to content

Commit

Permalink
Initial support for external dir hasher
Browse files Browse the repository at this point in the history
  • Loading branch information
abergmeier authored Dec 18, 2023
1 parent 7d621d6 commit 33e86fa
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/builder-source-dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct BuilderSourceDir
BuilderSource parent;

char *path;
char **hash_command;
char **skip;
};

Expand All @@ -51,6 +52,7 @@ enum {
PROP_0,
PROP_PATH,
PROP_SKIP,
PROP_DIR_HASH_CMD,
LAST_PROP
};

Expand All @@ -75,6 +77,10 @@ builder_source_dir_get_property (GObject *object,

switch (prop_id)
{
case PROP_DIR_HASH_CMD:
g_value_set_boxed(value, self->dir_hash_cmd;
break;

case PROP_PATH:
g_value_set_string (value, self->path);
break;
Expand All @@ -99,6 +105,12 @@ builder_source_dir_set_property (GObject *object,

switch (prop_id)
{
case PROP_DIR_HASH_CMD:
tmp = self->dir_hash_cmd;
self->dir_hash_cmd = g_strdupv (g_value_get_boxed (value));
g_strfreev (tmp);
break;

case PROP_PATH:
g_free (self->path);
self->path = g_value_dup_string (value);
Expand Down Expand Up @@ -271,8 +283,13 @@ builder_source_dir_checksum (BuilderSource *source,
BuilderCache *cache,
BuilderContext *context)
{
/* We can't realistically checksum a directory, so always rebuild */
builder_cache_checksum_random (cache);
if (source.dir_hash_cmd) {
call_me(cache);
} else {
/* Checksumming a directory is a non-trivial pursuit. We currently opt to not integrate into flatpak directly
and rather always rebuild */
builder_cache_checksum_random (cache);
}
}

static void
Expand All @@ -292,6 +309,14 @@ builder_source_dir_class_init (BuilderSourceDirClass *klass)
source_class->update = builder_source_dir_update;
source_class->checksum = builder_source_dir_checksum;

g_object_class_install_property (object_class,
PROP_DIR_HASH_CMD,
g_param_spec_boxed ("dir_hash_cmd",
"",
"",
G_TYPE_STRV,
G_PARAM_READWRITE));

g_object_class_install_property (object_class,
PROP_PATH,
g_param_spec_string ("path",
Expand Down

0 comments on commit 33e86fa

Please sign in to comment.