repo: Disable uncompressed object cache on non-writable repos
While we did support disabling the uncompressed-objects-cache per-repository: 1) We didn't actually respect that operation when doing CHECKOUT_MODE_USER on archive-z2 repositories 2) It'd be better to automatically detect we can't write to the repo and disable the uncompressed cache then.
This commit is contained in:
parent
d546abfa2a
commit
884a9b27e9
|
|
@ -392,7 +392,8 @@ checkout_one_file_at (OstreeRepo *repo,
|
|||
gboolean is_bare = (current_repo->mode == OSTREE_REPO_MODE_BARE
|
||||
&& mode == OSTREE_REPO_CHECKOUT_MODE_NONE);
|
||||
gboolean is_archive_z2_with_cache = (current_repo->mode == OSTREE_REPO_MODE_ARCHIVE_Z2
|
||||
&& mode == OSTREE_REPO_CHECKOUT_MODE_USER);
|
||||
&& mode == OSTREE_REPO_CHECKOUT_MODE_USER
|
||||
&& current_repo->enable_uncompressed_cache);
|
||||
|
||||
/* But only under these conditions */
|
||||
if (is_bare || is_archive_z2_with_cache)
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ struct OstreeRepo {
|
|||
GPtrArray *cached_content_indexes;
|
||||
|
||||
gboolean inited;
|
||||
gboolean writable;
|
||||
gboolean in_transaction;
|
||||
gboolean disable_fsync;
|
||||
GHashTable *loose_object_devino_hash;
|
||||
|
|
|
|||
|
|
@ -752,14 +752,14 @@ ostree_repo_open (OstreeRepo *self,
|
|||
if (self->inited)
|
||||
return TRUE;
|
||||
|
||||
if (!g_file_test (gs_file_get_path_cached (self->objects_dir), G_FILE_TEST_IS_DIR))
|
||||
if (!gs_file_open_dir_fd (self->objects_dir, &self->objects_dir_fd, cancellable, error))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
|
||||
"Couldn't find objects directory '%s'",
|
||||
gs_file_get_path_cached (self->objects_dir));
|
||||
g_prefix_error (error, "Reading objects/ directory: ");
|
||||
goto out;
|
||||
}
|
||||
|
||||
self->writable = faccessat (AT_FDCWD, gs_file_get_path_cached (self->objects_dir), W_OK, 0) == 0;
|
||||
|
||||
self->config = g_key_file_new ();
|
||||
if (!g_key_file_load_from_file (self->config, gs_file_get_path_cached (self->config_file), 0, error))
|
||||
{
|
||||
|
|
@ -812,9 +812,14 @@ ostree_repo_open (OstreeRepo *self,
|
|||
}
|
||||
}
|
||||
|
||||
if (self->writable)
|
||||
{
|
||||
if (!ot_keyfile_get_boolean_with_default (self->config, "core", "enable-uncompressed-cache",
|
||||
TRUE, &self->enable_uncompressed_cache, error))
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
self->enable_uncompressed_cache = FALSE;
|
||||
|
||||
{
|
||||
gboolean do_fsync;
|
||||
|
|
@ -837,13 +842,10 @@ ostree_repo_open (OstreeRepo *self,
|
|||
}
|
||||
}
|
||||
|
||||
if (!gs_file_open_dir_fd (self->objects_dir, &self->objects_dir_fd, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!gs_file_open_dir_fd (self->tmp_dir, &self->tmp_dir_fd, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (self->mode == OSTREE_REPO_MODE_ARCHIVE_Z2)
|
||||
if (self->mode == OSTREE_REPO_MODE_ARCHIVE_Z2 && self->enable_uncompressed_cache)
|
||||
{
|
||||
if (!gs_file_ensure_directory (self->uncompressed_objects_dir, TRUE, cancellable, error))
|
||||
goto out;
|
||||
|
|
|
|||
Loading…
Reference in New Issue