[ostree] fsck: add argument --add-tombstones
- From: Giuseppe Scrivano <gscrivano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] fsck: add argument --add-tombstones
- Date: Tue, 3 Nov 2015 09:00:56 +0000 (UTC)
commit 29c425e742accc9651bb9bc2c0c6e5bbc602cc24
Author: Giuseppe Scrivano <gscrivan redhat com>
Date: Wed Oct 28 14:23:35 2015 +0100
fsck: add argument --add-tombstones
It is used to create tombstones for missing commits
Signed-off-by: Giuseppe Scrivano <gscrivan redhat com>
doc/ostree-fsck.xml | 7 +++++++
src/ostree/ot-builtin-fsck.c | 38 ++++++++++++++++++++++++++++++++++++--
2 files changed, 43 insertions(+), 2 deletions(-)
---
diff --git a/doc/ostree-fsck.xml b/doc/ostree-fsck.xml
index 68107f5..2cae92c 100644
--- a/doc/ostree-fsck.xml
+++ b/doc/ostree-fsck.xml
@@ -78,6 +78,13 @@ Boston, MA 02111-1307, USA.
Remove corrupted objects.
</para></listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><option>--add-tombstones</option></term>
+ <listitem><para>
+ Add tombstone commit for referenced but missing commits.
+ </para></listitem>
+ </varlistentry>
</variablelist>
</refsect1>
diff --git a/src/ostree/ot-builtin-fsck.c b/src/ostree/ot-builtin-fsck.c
index 69bb2e4..d16ead8 100644
--- a/src/ostree/ot-builtin-fsck.c
+++ b/src/ostree/ot-builtin-fsck.c
@@ -30,8 +30,10 @@
static gboolean opt_quiet;
static gboolean opt_delete;
+static gboolean opt_add_tombstones;
static GOptionEntry options[] = {
+ { "add-tombstones", 0, 0, G_OPTION_ARG_NONE, &opt_add_tombstones, "Add tombstones for missing commits",
NULL },
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &opt_quiet, "Only print error messages", NULL },
{ "delete", 0, 0, G_OPTION_ARG_NONE, &opt_delete, "Remove corrupted objects", NULL },
{ NULL }
@@ -246,7 +248,7 @@ ostree_builtin_fsck (int argc, char **argv, GCancellable *cancellable, GError **
guint n_partial = 0;
g_autoptr(GHashTable) objects = NULL;
g_autoptr(GHashTable) commits = NULL;
-
+ g_autoptr(GPtrArray) tombstones = NULL;
context = g_option_context_new ("- Check the repository for consistency");
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo,
cancellable, error))
@@ -264,6 +266,9 @@ ostree_builtin_fsck (int argc, char **argv, GCancellable *cancellable, GError **
g_hash_table_iter_init (&hash_iter, objects);
+ if (opt_add_tombstones)
+ tombstones = g_ptr_array_new_with_free_func (g_free);
+
while (g_hash_table_iter_next (&hash_iter, &key, &value))
{
GVariant *serialized_key = key;
@@ -281,6 +286,9 @@ ostree_builtin_fsck (int argc, char **argv, GCancellable *cancellable, GError **
if (commitstate & OSTREE_REPO_COMMIT_STATE_PARTIAL)
{
n_partial++;
+
+ if (opt_add_tombstones)
+ g_ptr_array_add (tombstones, g_strdup (checksum));
}
else
g_hash_table_insert (commits, g_variant_ref (serialized_key), serialized_key);
@@ -297,7 +305,33 @@ ostree_builtin_fsck (int argc, char **argv, GCancellable *cancellable, GError **
cancellable, error))
goto out;
- if (n_partial > 0)
+ if (opt_add_tombstones)
+ {
+ guint i;
+ if (tombstones->len)
+ {
+ GError *temp_error = NULL;
+ gboolean tombstone_commits = FALSE;
+ GKeyFile *config = ostree_repo_get_config (repo);
+ tombstone_commits = g_key_file_get_boolean (config, "core", "tombstone-commits", &temp_error);
+ /* tombstone_commits is FALSE either if it is not found or it is really set to FALSE in the config
file. */
+ if (!tombstone_commits)
+ {
+ g_clear_error (&temp_error);
+ g_key_file_set_boolean (config, "core", "tombstone-commits", TRUE);
+ if (!ostree_repo_write_config (repo, config, error))
+ goto out;
+ }
+ }
+ for (i = 0; i < tombstones->len; i++)
+ {
+ const char *checksum = tombstones->pdata[i];
+ g_print ("Adding tombstone for commit %s\n", checksum);
+ if (!ostree_repo_delete_object (repo, OSTREE_OBJECT_TYPE_COMMIT, checksum, cancellable, error))
+ goto out;
+ }
+ }
+ else if (n_partial > 0)
{
g_print ("%u partial commits not verified\n", n_partial);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]