[ostree] fsck: create a tombstone when the parent is missing



commit 0dee70bcd64d5d0721d97c9b01e967a23945f75e
Author: Giuseppe Scrivano <gscrivan redhat com>
Date:   Thu Nov 5 15:18:39 2015 +0100

    fsck: create a tombstone when the parent is missing
    
    Change the previous logic that a tombstone commit was created when
    a partialcommit is found.
    
    Signed-off-by: Giuseppe Scrivano <gscrivan redhat com>

 src/ostree/ot-builtin-fsck.c |   32 ++++++++++++++++++++++++++------
 1 files changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/src/ostree/ot-builtin-fsck.c b/src/ostree/ot-builtin-fsck.c
index b192683..5afa435 100644
--- a/src/ostree/ot-builtin-fsck.c
+++ b/src/ostree/ot-builtin-fsck.c
@@ -275,21 +275,41 @@ ostree_builtin_fsck (int argc, char **argv, GCancellable *cancellable, GError **
       const char *checksum;
       OstreeObjectType objtype;
       OstreeRepoCommitState commitstate = 0;
+      g_autoptr(GVariant) commit = NULL;
 
       ostree_object_name_deserialize (serialized_key, &checksum, &objtype);
 
       if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
         {
-          if (!ostree_repo_load_commit (repo, checksum, NULL, &commitstate, error))
+          if (!ostree_repo_load_commit (repo, checksum, &commit, &commitstate, error))
             goto out;
 
-          if (commitstate & OSTREE_REPO_COMMIT_STATE_PARTIAL)
+          if (opt_add_tombstones)
             {
-              n_partial++;
-
-              if (opt_add_tombstones)
-                g_ptr_array_add (tombstones, g_strdup (checksum));
+              GError *local_error = NULL;
+              const char *parent = ostree_commit_get_parent (commit);
+              if (parent)
+                {
+                  g_autoptr(GVariant) parent_commit = NULL;
+                  if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, parent,
+                                                 &parent_commit, &local_error))
+                    {
+                      if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
+                        {
+                          g_ptr_array_add (tombstones, g_strdup (checksum));
+                          g_clear_error (&local_error);
+                        }
+                      else
+                        {
+                          g_propagate_error (error, local_error);
+                          goto out;
+                        }
+                    }
+                }
             }
+
+          if (commitstate & OSTREE_REPO_COMMIT_STATE_PARTIAL)
+            n_partial++;
           else
             g_hash_table_insert (commits, g_variant_ref (serialized_key), serialized_key);
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]