prune: Don't fail on partial commits

If a commit only pull has been done, then the commit object exists in
the object store in addition to the commitpartial file. Traversing this
partial commit will likely fail, but that's expected. If traverse
returns a G_IO_ERROR_NOT_FOUND in this case, continue with pruning.

https://bugzilla.gnome.org/show_bug.cgi?id=764091
This commit is contained in:
Dan Nicholson 2016-03-23 09:47:51 -07:00 committed by Colin Walters
parent ddf0a02f88
commit 2ae7f619b2
1 changed files with 42 additions and 6 deletions

View File

@ -303,12 +303,30 @@ ostree_repo_prune (OstreeRepo *self,
while (g_hash_table_iter_next (&hash_iter, &key, &value))
{
const char *checksum = value;
OstreeRepoCommitState commitstate;
GError *local_error = NULL;
if (!ostree_repo_load_commit (self, checksum, NULL, &commitstate,
error))
goto out;
if (!ostree_repo_traverse_commit_union (self, checksum, depth, data.reachable,
cancellable, error))
cancellable, &local_error))
{
/* Don't fail traversing a partial commit */
if ((commitstate & OSTREE_REPO_COMMIT_STATE_PARTIAL) > 0 &&
g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{
g_clear_error (&local_error);
}
else
{
g_propagate_error (error, local_error);
goto out;
}
}
}
}
if (!ostree_repo_list_objects (self, OSTREE_REPO_LIST_OBJECTS_ALL, &objects,
cancellable, error))
@ -322,15 +340,33 @@ ostree_repo_prune (OstreeRepo *self,
GVariant *serialized_key = key;
const char *checksum;
OstreeObjectType objtype;
OstreeRepoCommitState commitstate;
GError *local_error = NULL;
ostree_object_name_deserialize (serialized_key, &checksum, &objtype);
if (objtype != OSTREE_OBJECT_TYPE_COMMIT)
continue;
if (!ostree_repo_traverse_commit_union (self, checksum, depth, data.reachable,
cancellable, error))
if (!ostree_repo_load_commit (self, checksum, NULL, &commitstate,
error))
goto out;
if (!ostree_repo_traverse_commit_union (self, checksum, depth, data.reachable,
cancellable, &local_error))
{
/* Don't fail traversing a partial commit */
if ((commitstate & OSTREE_REPO_COMMIT_STATE_PARTIAL) > 0 &&
g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{
g_clear_error (&local_error);
}
else
{
g_propagate_error (error, local_error);
goto out;
}
}
}
}