From 8c6402d5c1e125e50c28f055a539a8ded1ddc645 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Thu, 20 Jun 2019 09:00:41 -0400 Subject: [PATCH] core: Check if cached pkg is in partial state Otherwise, we won't redownload, and then won't be able to checkout the package during assembly. This is important, so that we can survive an `ostree fsck --delete`. See e.g.: https://discussion.fedoraproject.org/t/i-cant-boot-into-either-my-latest-or-previous-ostree-after-running-restorecon Closes: #1860 Approved by: cgwalters --- src/libpriv/rpmostree-core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libpriv/rpmostree-core.c b/src/libpriv/rpmostree-core.c index 7742fc2f..f24cee41 100644 --- a/src/libpriv/rpmostree-core.c +++ b/src/libpriv/rpmostree-core.c @@ -1333,9 +1333,16 @@ find_pkg_in_ostree (RpmOstreeContext *self, GLNX_AUTO_PREFIX_ERROR (errprefix, error); g_autoptr(GVariant) commit = NULL; - if (!ostree_repo_load_commit (repo, cached_rev, &commit, NULL, error)) + OstreeRepoCommitState commitstate; + if (!ostree_repo_load_commit (repo, cached_rev, &commit, &commitstate, error)) return FALSE; g_assert (commit); + + /* If the commit is partial, then we need to redownload. This can happen if e.g. corrupted + * commit objects were deleted with `ostree fsck --delete`. */ + if (commitstate & OSTREE_REPO_COMMIT_STATE_PARTIAL) + return TRUE; /* Note early return */ + g_autoptr(GVariant) metadata = g_variant_get_child_value (commit, 0); g_autoptr(GVariantDict) metadata_dict = g_variant_dict_new (metadata);