Add public API for fsck, use it before loading metadata

A while ago I did `truncate -s 0 /path/to/repo/00/123.commit`, and expected a
checksum error, but I actually got a validation error due to us loading the
commit into a variant and trying to parse out the parent checksum, etc.

I first started by changing the `load_and_fsck_one_object()` function to
checksum before loading, but the problem is that we do a traverse of all objects
first. Fixing this is going to require an `OSTREE_REPO_COMMIT_TRAVER_FLAG_FSCK`
or something.

In the meantime at least though, let's add a public API to fsck a single object
which *does* checksum cleanly before parsing the object, and change the `fsck`
command to use it.

We then change the fsck binary to do this while iterating over the refs
and finding the commit object.  This way we'll at least get a checksum
first for commit objects, even if not dirtree/dirmeta.

Closes: #1364
Approved by: jlebon
This commit is contained in:
Colin Walters authored and Atomic Bot committed 2017-12-12 14:03:09 +00:00
1 parent 102f30f6cc
commit 73d910e82e
8 files changed
+160 -106

No files matched your search

+1
View File
@@ -348,6 +348,7 @@ ostree_repo_import_object_from_with_trust
ostree_repo_import_archive_to_mtree
ostree_repo_export_tree_to_archive
ostree_repo_delete_object
ostree_repo_fsck_object
OstreeRepoCommitFilterResult
OstreeRepoCommitFilter
OstreeRepoCommitModifier