Skip to content

Commit

Permalink
lib/pull: Honor requiring static deltas for scratch delta
Browse files Browse the repository at this point in the history
If a scratch delta exists and the caller has required static deltas, use
it instead of the heuristic about existing commits.
  • Loading branch information
dbnicholson committed Feb 12, 2020
1 parent d1f81c3 commit 3c0fadc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/libostree/ostree-repo-pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 10 additions & 2 deletions tests/pull-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3c0fadc

Please sign in to comment.