diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c index e6a15b1956..0a373b681c 100644 --- a/src/libostree/ostree-repo-pull.c +++ b/src/libostree/ostree-repo-pull.c @@ -2726,12 +2726,14 @@ get_best_static_delta_start_for (OtPullData *pull_data, memcpy (out_result->from_revision, newest_candidate, OSTREE_SHA256_STRING_LEN+1); } - /* If a from-scratch delta is available, we don’t want to use it if the ref - * or any of its ancestors already exists locally and is not partial. In - * that case only some of the objects in the new commit may be needed, so - * doing an object pull is likely more bandwidth efficient. + /* If a from-scratch delta is available and deltas aren't required, we don’t + * want to use it if the ref or any of its ancestors already exists locally + * and is not partial. In that case only some of the objects in the new + * commit may be needed, so doing an object pull is likely more bandwidth + * efficient. */ if (out_result->result == DELTA_SEARCH_RESULT_SCRATCH && + !pull_data->require_static_deltas && cur_revision != NULL && normal_commit_reachable (pull_data->repo, cur_revision)) { diff --git a/tests/pull-test.sh b/tests/pull-test.sh index d0ba4dcd1b..4f2b833130 100644 --- a/tests/pull-test.sh +++ b/tests/pull-test.sh @@ -54,7 +54,7 @@ function verify_initial_contents() { assert_file_has_content baz/cow '^moo$' } -num_tests=39 +num_tests=40 # 3 tests needs GPG support num_gpg_tests=3 if has_gpgme; then @@ -709,5 +709,15 @@ ${CMD_PREFIX} ostree --repo=repo pull origin scratch@${rev2} ${CMD_PREFIX} ostree --repo=repo pull origin scratch echo "ok scratch delta (normal parent)" +# Pull with a normal parent but require static deltas. This should fail +# because it tries to pull the scratch delta. +repo_init --no-gpg-verify +${CMD_PREFIX} ostree --repo=repo pull origin scratch@${rev2} +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" +echo "ok scratch delta (require static deltas with normal parent)" + # Clean up the deltas so we don't leave a corrupt one around rm ostree-srv/gnomerepo/deltas -rf