Re-open the cache OstreeRepo if we change the min-free-space-percent

Without this it doesnn't work the first time the property is set.
tingping/wmclass
Alexander Larsson 2017-09-08 15:47:56 +02:00
parent 21cd4963b1
commit d91037be22
1 changed files with 19 additions and 7 deletions

View File

@ -229,13 +229,10 @@ builder_cache_open (BuilderCache *self,
GError **error)
{
g_autoptr(GKeyFile) config = NULL;
g_autofree char *old_mfsp = NULL;
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 (builder_context_get_cache_dir (self->context), NULL))
{
g_autoptr(GFile) parent = g_file_get_parent (builder_context_get_cache_dir (self->context));
@ -251,10 +248,25 @@ builder_cache_open (BuilderCache *self,
return FALSE;
config = ostree_repo_copy_config (self->repo);
g_key_file_set_value (config, "core", "min-free-space-percent", "0");
if (!ostree_repo_write_config (self->repo, config, error))
return FALSE;
old_mfsp = g_key_file_get_value (config, "core", "min-free-space-percent", NULL);
if (g_strcmp0 (old_mfsp, "0") != 0)
{
g_key_file_set_value (config, "core", "min-free-space-percent", "0");
if (!ostree_repo_write_config (self->repo, config, error))
return FALSE;
/* Re-open */
g_clear_object (&self->repo);
self->repo = ostree_repo_new (builder_context_get_cache_dir (self->context));
if (!ostree_repo_open (self->repo, NULL, error))
return FALSE;
}
/* 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);
/* At one point we used just the branch name as a ref, make sure to
* remove this to handle using the branch as a subdir */