diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c index 5f08000d05..64abc742a4 100644 --- a/src/libostree/ostree-repo-pull.c +++ b/src/libostree/ostree-repo-pull.c @@ -1125,6 +1125,32 @@ is_parent_commit (OtPullData *pull_data, return g_hash_table_contains (pull_data->commit_to_depth, checksum); } +static gboolean +try_missing_parent_tombstone (OtPullData *pull_data, + FetchObjectData *fetch_data, + const char *checksum, + GCancellable *cancellable, + GError **error) +{ + /* If the remote repo supports tombstone commits, check if the commit + * was intentionally deleted. + */ + if (!pull_data->has_tombstone_commits) + return TRUE; + + if (pull_data->remote_repo_local) + return _ostree_repo_import_object (pull_data->repo, pull_data->remote_repo_local, + OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT, + checksum, pull_data->importflags, + cancellable, error); + else + { + enqueue_one_object_request (pull_data, checksum, OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT, + fetch_data->path, FALSE, FALSE, NULL); + return TRUE; + } +} + static void meta_fetch_on_complete (GObject *object, GAsyncResult *result, @@ -1167,20 +1193,16 @@ meta_fetch_on_complete (GObject *object, } /* When traversing parents, do not fail on a missing commit. - * We may be pulling from a partial repository that ends in - * a dangling parent reference. */ + * We may be pulling from a partial repository that ends in a + * dangling parent reference. This logic should match the + * local case in scan_one_metadata_object. + */ else if (objtype == OSTREE_OBJECT_TYPE_COMMIT && pull_data->maxdepth != 0 && is_parent_commit (pull_data, checksum)) { g_clear_error (&local_error); - /* If the remote repo supports tombstone commits, check if the commit was intentionally - deleted. */ - if (pull_data->has_tombstone_commits) - { - enqueue_one_object_request (pull_data, checksum, OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT, - fetch_data->path, FALSE, FALSE, NULL); - } + try_missing_parent_tombstone (pull_data, fetch_data, checksum, NULL, NULL); } } @@ -1827,7 +1849,10 @@ scan_one_metadata_object (OtPullData *pull_data, { /* When traversing parents, do not fail on a missing commit. * We may be pulling from a partial repository that ends in a - * dangling parent reference. + * dangling parent reference. This logic should match the + * remote case in meta_fetch_on_complete. + * + * Note early return. */ if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) && objtype == OSTREE_OBJECT_TYPE_COMMIT && @@ -1835,21 +1860,8 @@ scan_one_metadata_object (OtPullData *pull_data, is_parent_commit (pull_data, checksum)) { g_clear_error (&local_error); - - /* If the remote repo supports tombstone commits, check if - * the commit was intentionally deleted. - */ - if (pull_data->has_tombstone_commits) - { - if (!_ostree_repo_import_object (pull_data->repo, pull_data->remote_repo_local, - OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT, - checksum, pull_data->importflags, - cancellable, error)) - return FALSE; - } - - /* Note early return */ - return TRUE; + return try_missing_parent_tombstone (pull_data, NULL, checksum, + cancellable, error); } else {