From c304703e1d88265f1fd76744b1abaa2ddf415a9e Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 12 Oct 2020 15:57:53 +0200 Subject: [PATCH] deltas: Make ostree_repo_static_delta_reindex() public It is useful to be able to trigger this without having to regenerate the summary. For example, if you are not using summaries, or ar generating the summaries yourself. --- apidoc/ostree-sections.txt | 1 + src/libostree/libostree-devel.sym | 1 + src/libostree/ostree-repo-static-delta-core.c | 26 ++++++++++++++++--- src/libostree/ostree-repo.c | 2 +- src/libostree/ostree-repo.h | 17 ++++++++++++ 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/apidoc/ostree-sections.txt b/apidoc/ostree-sections.txt index ea37823b..81dc8890 100644 --- a/apidoc/ostree-sections.txt +++ b/apidoc/ostree-sections.txt @@ -413,6 +413,7 @@ ostree_repo_list_objects ostree_repo_list_commit_objects_starting_with ostree_repo_list_static_delta_names ostree_repo_list_static_delta_indexes +ostree_repo_static_delta_reindex OstreeStaticDeltaGenerateOpt ostree_repo_static_delta_generate ostree_repo_static_delta_execute_offline_with_signature diff --git a/src/libostree/libostree-devel.sym b/src/libostree/libostree-devel.sym index 1350341c..82d6a9b6 100644 --- a/src/libostree/libostree-devel.sym +++ b/src/libostree/libostree-devel.sym @@ -20,6 +20,7 @@ LIBOSTREE_2020.8 { global: ostree_repo_list_static_delta_indexes; + ostree_repo_static_delta_reindex; } LIBOSTREE_2020.7; /* Stub section for the stable release *after* this development one; don't diff --git a/src/libostree/ostree-repo-static-delta-core.c b/src/libostree/ostree-repo-static-delta-core.c index c58e3683..670a10a5 100644 --- a/src/libostree/ostree-repo-static-delta-core.c +++ b/src/libostree/ostree-repo-static-delta-core.c @@ -1238,11 +1238,29 @@ file_has_content (OstreeRepo *repo, return g_bytes_equal (existing_data, data); } +/** + * ostree_repo_static_delta_reindex: + * @repo: Repo + * @flags: Flags affecting the indexing operation + * @opt_to_commit: ASCII SHA256 checksum of target commit, or %NULL to index all targets + * @cancellable: Cancellable + * @error: Error + * + * The delta index for a particular commit lists all the existing deltas that can be used + * when downloading that commit. This operation regenerates these indexes, either for + * a particular commit (if @opt_to_commit is non-%NULL), or for all commits that + * are reachable by an existing delta (if @opt_to_commit is %NULL). + * + * This is normally called automatically when the summary is updated in ostree_repo_regenerate_summary(). + * + * Locking: shared + */ gboolean -_ostree_repo_static_delta_reindex (OstreeRepo *repo, - const char *opt_to_commit, - GCancellable *cancellable, - GError **error) +ostree_repo_static_delta_reindex (OstreeRepo *repo, + OstreeStaticDeltaIndexFlags flags, + const char *opt_to_commit, + GCancellable *cancellable, + GError **error) { g_autoptr(GPtrArray) all_deltas = NULL; g_autoptr(GHashTable) deltas_to_commit_ht = NULL; /* map: to checksum -> ptrarray of from checksums (or NULL) */ diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c index 9d9146b3..c22a6666 100644 --- a/src/libostree/ostree-repo.c +++ b/src/libostree/ostree-repo.c @@ -5935,7 +5935,7 @@ ostree_repo_regenerate_summary (OstreeRepo *self, g_variant_ref_sink (summary); } - if (!_ostree_repo_static_delta_reindex (self, NULL, cancellable, error)) + if (!ostree_repo_static_delta_reindex (self, 0, NULL, cancellable, error)) return FALSE; if (!_ostree_repo_file_replace_contents (self, diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h index a3c5dc77..6201e7b3 100644 --- a/src/libostree/ostree-repo.h +++ b/src/libostree/ostree-repo.h @@ -1074,6 +1074,23 @@ gboolean ostree_repo_static_delta_generate (OstreeRepo *self, GCancellable *cancellable, GError **error); +/** + * OstreeStaticDeltaIndexFlags: + * @OSTREE_STATIC_DELTA_INDEX_FLAGS_NONE: No special flags + * + * Flags controlling static delta index generation. + */ +typedef enum { + OSTREE_STATIC_DELTA_INDEX_FLAGS_NONE = 0, +} OstreeStaticDeltaIndexFlags; + +_OSTREE_PUBLIC +gboolean ostree_repo_static_delta_reindex (OstreeRepo *repo, + OstreeStaticDeltaIndexFlags flags, + const char *opt_to_commit, + GCancellable *cancellable, + GError **error); + _OSTREE_PUBLIC gboolean ostree_repo_static_delta_execute_offline_with_signature (OstreeRepo *self, GFile *dir_or_file,