[ostree] prune: Don't fail on partial commits
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] prune: Don't fail on partial commits
- Date: Wed, 23 Mar 2016 19:35:48 +0000 (UTC)
commit 2ae7f619b2618e95dd3c3221041876d82a360fcf
Author: Dan Nicholson <nicholson endlessm com>
Date: Wed Mar 23 09:47:51 2016 -0700
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
src/libostree/ostree-repo-prune.c | 48 ++++++++++++++++++++++++++++++++----
1 files changed, 42 insertions(+), 6 deletions(-)
---
diff --git a/src/libostree/ostree-repo-prune.c b/src/libostree/ostree-repo-prune.c
index 2d93a9c..eca2cff 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;
+ }
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]