diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c index 1f5e342b96..81dad7aa15 100644 --- a/src/libostree/ostree-repo-pull.c +++ b/src/libostree/ostree-repo-pull.c @@ -3455,10 +3455,10 @@ initiate_request (OtPullData *pull_data, * the ref already exists locally, since we are likely only a few * commits out of date; so doing an object pull is likely more * bandwidth efficient. */ - if (delta_from_revision != NULL) - queue_scan_one_metadata_object (pull_data, to_revision, OSTREE_OBJECT_TYPE_COMMIT, NULL, 0, ref); - else + if (pull_data->require_static_deltas || delta_from_revision == NULL) enqueue_one_static_delta_superblock_request (pull_data, NULL, to_revision, ref); + else + queue_scan_one_metadata_object (pull_data, to_revision, OSTREE_OBJECT_TYPE_COMMIT, NULL, 0, ref); } break; case DELTA_SEARCH_RESULT_UNCHANGED: diff --git a/tests/pull-test.sh b/tests/pull-test.sh index a4fe88b85f..2ee5bb05f0 100644 --- a/tests/pull-test.sh +++ b/tests/pull-test.sh @@ -639,8 +639,16 @@ if ${CMD_PREFIX} ostree --repo=repo pull origin scratch 2>err.txt; then fi assert_file_has_content err.txt "Invalid checksum for static delta" -# Fully pull the parent commit then pull the HEAD. This should succeed -# with an object pull. +# Fully pull the parent commit then pull the HEAD with +# --require-static-deltas. This should succeed with an object pull. +${CMD_PREFIX} ostree --repo=repo pull origin scratch@${old_rev} +if ${CMD_PREFIX} ostree --repo=repo pull --require-static-deltas origin scratch 2>err.txt; then + assert_not_reached "pull of corrupt scratch delta unexpectedly succeeded" +fi +assert_file_has_content err.txt "Invalid checksum for static delta" + +# Pull the HEAD again without --require-static-deltas. This should +# succeed with an object pull. ${CMD_PREFIX} ostree --repo=repo pull origin scratch@${old_rev} ${CMD_PREFIX} ostree --repo=repo pull origin scratch ${CMD_PREFIX} ostree --repo=repo fsck