[ostree] repo: Disable uncompressed object cache on non-writable repos
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] repo: Disable uncompressed object cache on non-writable repos
- Date: Thu, 16 Oct 2014 19:08:46 +0000 (UTC)
commit 884a9b27e91c728c5b25799e807129cd3fdf1ba4
Author: Colin Walters <walters verbum org>
Date: Thu Oct 16 14:54:34 2014 -0400
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.
src/libostree/ostree-repo-checkout.c | 3 ++-
src/libostree/ostree-repo-private.h | 1 +
src/libostree/ostree-repo.c | 24 +++++++++++++-----------
3 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/src/libostree/ostree-repo-checkout.c b/src/libostree/ostree-repo-checkout.c
index 417e11f..2963996 100644
--- a/src/libostree/ostree-repo-checkout.c
+++ b/src/libostree/ostree-repo-checkout.c
@@ -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)
diff --git a/src/libostree/ostree-repo-private.h b/src/libostree/ostree-repo-private.h
index 34f6cde..ad512f9 100644
--- a/src/libostree/ostree-repo-private.h
+++ b/src/libostree/ostree-repo-private.h
@@ -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;
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index c706640..bddfbfb 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -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 (!ot_keyfile_get_boolean_with_default (self->config, "core", "enable-uncompressed-cache",
- TRUE, &self->enable_uncompressed_cache, error))
- goto out;
+ 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]