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 authored and Colin Walters committed 2016-03-23 15:34:17 -04:00
1 parent ddf0a02f88
commit 2ae7f619b2
1 file changed
+42 -6
+42 -6
View File
@@ -303,10 +303,28 @@ ostree_repo_prune (OstreeRepo *self,
while (g_hash_table_iter_next (&hash_iter, &key, &value))
{
const char *checksum = value;
if (!ostree_repo_traverse_commit_union (self, checksum, depth, data.reachable,
cancellable, error))
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, &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;
}
}
}
}
@@ -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;
}
}
}
}