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>
This commit is contained in:
Giuseppe Scrivano 2015-11-05 15:18:39 +01:00
parent 0aa836c205
commit 0dee70bcd6
1 changed files with 26 additions and 6 deletions

View File

@ -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)
{
n_partial++;
if (opt_add_tombstones)
{
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);
}