Skip to content

Commit 3c0fadc

Browse files
committed
lib/pull: Honor requiring static deltas for scratch delta
If a scratch delta exists and the caller has required static deltas, use it instead of the heuristic about existing commits.
1 parent d1f81c3 commit 3c0fadc

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/libostree/ostree-repo-pull.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3455,10 +3455,10 @@ initiate_request (OtPullData *pull_data,
34553455
* the ref already exists locally, since we are likely only a few
34563456
* commits out of date; so doing an object pull is likely more
34573457
* bandwidth efficient. */
3458-
if (delta_from_revision != NULL)
3459-
queue_scan_one_metadata_object (pull_data, to_revision, OSTREE_OBJECT_TYPE_COMMIT, NULL, 0, ref);
3460-
else
3458+
if (pull_data->require_static_deltas || delta_from_revision == NULL)
34613459
enqueue_one_static_delta_superblock_request (pull_data, NULL, to_revision, ref);
3460+
else
3461+
queue_scan_one_metadata_object (pull_data, to_revision, OSTREE_OBJECT_TYPE_COMMIT, NULL, 0, ref);
34623462
}
34633463
break;
34643464
case DELTA_SEARCH_RESULT_UNCHANGED:

tests/pull-test.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,16 @@ if ${CMD_PREFIX} ostree --repo=repo pull origin scratch 2>err.txt; then
639639
fi
640640
assert_file_has_content err.txt "Invalid checksum for static delta"
641641
642-
# Fully pull the parent commit then pull the HEAD. This should succeed
643-
# with an object pull.
642+
# Fully pull the parent commit then pull the HEAD with
643+
# --require-static-deltas. This should succeed with an object pull.
644+
${CMD_PREFIX} ostree --repo=repo pull origin scratch@${old_rev}
645+
if ${CMD_PREFIX} ostree --repo=repo pull --require-static-deltas origin scratch 2>err.txt; then
646+
assert_not_reached "pull of corrupt scratch delta unexpectedly succeeded"
647+
fi
648+
assert_file_has_content err.txt "Invalid checksum for static delta"
649+
650+
# Pull the HEAD again without --require-static-deltas. This should
651+
# succeed with an object pull.
644652
${CMD_PREFIX} ostree --repo=repo pull origin scratch@${old_rev}
645653
${CMD_PREFIX} ostree --repo=repo pull origin scratch
646654
${CMD_PREFIX} ostree --repo=repo fsck

0 commit comments

Comments
 (0)