Don't copy summary for collection-ref mirror subset pulls

When we're only pulling a subset of the refs available in the remote, it
doesn't make sense to copy the remote's summary (which may not be valid
for the local repo). This makes the check here match the one done
several lines above when we decide whether to error out if there's no
remote summary available.

This extends the fix in https://github.com/ostreedev/ostree/pull/935 for
the case of collection-refs.

Also, add a unit test for this issue, based on the existing one in
pull-test.sh.
This commit is contained in:
Matthew Leeds 2019-11-13 18:30:58 -08:00
parent cd37293b5a
commit 164b2aa35b
2 changed files with 15 additions and 2 deletions

View File

@ -4567,7 +4567,8 @@ ostree_repo_pull_with_options (OstreeRepo *self,
} }
} }
if (pull_data->is_mirror && pull_data->summary_data && !refs_to_fetch && !configured_branches) if (pull_data->is_mirror && pull_data->summary_data &&
!refs_to_fetch && !opt_collection_refs_set && !configured_branches)
{ {
GLnxFileReplaceFlags replaceflag = GLnxFileReplaceFlags replaceflag =
pull_data->repo->disable_fsync ? GLNX_FILE_REPLACE_NODATASYNC : 0; pull_data->repo->disable_fsync ? GLNX_FILE_REPLACE_NODATASYNC : 0;

View File

@ -23,7 +23,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh . $(dirname $0)/libtest.sh
echo '1..6' echo '1..7'
cd ${test_tmpdir} cd ${test_tmpdir}
@ -258,3 +258,15 @@ then
fi fi
echo "ok 6 pull refs from local repos" echo "ok 6 pull refs from local repos"
ostree_repo_init local-mirror
do_remote_add local-mirror collection-repo --collection-id org.example.CollectionRepo
# Generate a summary in the local mirror; don't use do_summary to avoid gpg
${CMD_PREFIX} ostree --repo=local-mirror summary --update
summarysig=$(sha256sum < local-mirror/summary | cut -f 1 -d ' ')
# Mirror subset of refs: A collection-ref version of https://github.com/ostreedev/ostree/issues/846
${CMD_PREFIX} ostree --repo=local-mirror find-remotes --pull --mirror --finders=config org.example.CollectionRepo goodcref1
newsummarysig=$(sha256sum < local-mirror/summary | cut -f 1 -d ' ')
assert_streq ${summarysig} ${newsummarysig}
echo "ok 7 mirror pull subset of collection-refs with summary"