summaryrefslogtreecommitdiff
path: root/src/libostree/ostree-repo-prune.c
diff options
context:
space:
mode:
authorDan Nicholson <nicholson@endlessm.com>2016-03-23 09:47:51 -0700
committerColin Walters <walters@verbum.org>2016-03-23 15:34:17 -0400
commit2ae7f619b2618e95dd3c3221041876d82a360fcf (patch)
tree0458cc2a229e9a306d2938cd9eced1420854ab60 /src/libostree/ostree-repo-prune.c
parentddf0a02f88f27dcb477295863f8f4369820c8254 (diff)
downloadostree-2ae7f619b2618e95dd3c3221041876d82a360fcf.tar.gz
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
Diffstat (limited to 'src/libostree/ostree-repo-prune.c')
-rw-r--r--src/libostree/ostree-repo-prune.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/src/libostree/ostree-repo-prune.c b/src/libostree/ostree-repo-prune.c
index 2d93a9cb..eca2cff6 100644
--- a/src/libostree/ostree-repo-prune.c
+++ b/src/libostree/ostree-repo-prune.c
@@ -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;
+ }
+ }
}
}