diff options
author | Colin Walters <walters@verbum.org> | 2015-04-06 14:19:08 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2015-05-06 08:07:20 -0400 |
commit | 5becd5ccad47fff009c1578fc870ffad66b940af (patch) | |
tree | aba09b96bfdb0cfed877654dd09c359a39d12a3c /src/ostree/ot-builtin-fsck.c | |
parent | 279308b5b95b587a306ab0841ebdd1b7ae4880e0 (diff) | |
download | ostree-5becd5ccad47fff009c1578fc870ffad66b940af.tar.gz |
Teach fsck about partial commits
An OSTree user noticed that `ostree fsck` would produce `missing
object` errors in the case of interrupted pulls.
It's possible to do e.g. `ostree pull --subpath=/usr/share/rpm ...`,
which gets you just that portion of the commit. The use case for this
was being able to see what changes would appear in an update before
actually downloading all of it.
(I think this would be better covered by static deltas, but those
aren't final yet, and `--subpath` predates it)
Further, `.commitpartial` is used as a successor to the `transaction`
symlink for more precise knowledge in the case where a pull was
interrupted that we needed to resume scanning.
So it makes sense for `ostree fsck` to be aware of it.
Diffstat (limited to 'src/ostree/ot-builtin-fsck.c')
-rw-r--r-- | src/ostree/ot-builtin-fsck.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/ostree/ot-builtin-fsck.c b/src/ostree/ot-builtin-fsck.c index ae1dcce4..8f340439 100644 --- a/src/ostree/ot-builtin-fsck.c +++ b/src/ostree/ot-builtin-fsck.c @@ -25,6 +25,7 @@ #include "ot-main.h" #include "ot-builtins.h" #include "ostree.h" +#include "ostree-cmdprivate.h" #include "otutil.h" static gboolean opt_quiet; @@ -242,6 +243,7 @@ ostree_builtin_fsck (int argc, char **argv, GCancellable *cancellable, GError ** GHashTableIter hash_iter; gpointer key, value; gboolean found_corruption = FALSE; + guint n_partial = 0; gs_unref_hashtable GHashTable *objects = NULL; gs_unref_hashtable GHashTable *commits = NULL; @@ -267,11 +269,22 @@ ostree_builtin_fsck (int argc, char **argv, GCancellable *cancellable, GError ** GVariant *serialized_key = key; const char *checksum; OstreeObjectType objtype; + OstreeRepoCommitState commitstate = 0; ostree_object_name_deserialize (serialized_key, &checksum, &objtype); if (objtype == OSTREE_OBJECT_TYPE_COMMIT) - g_hash_table_insert (commits, g_variant_ref (serialized_key), serialized_key); + { + if (!ostree_repo_load_commit (repo, checksum, NULL, &commitstate, 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); + } } g_clear_pointer (&objects, (GDestroyNotify) g_hash_table_unref); @@ -284,6 +297,11 @@ ostree_builtin_fsck (int argc, char **argv, GCancellable *cancellable, GError ** cancellable, error)) goto out; + if (n_partial > 0) + { + g_print ("%u partial commits not verified\n", n_partial); + } + if (found_corruption) { g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, |