From 164b2aa35bc2e39615f461decc90381d9bedd132 Mon Sep 17 00:00:00 2001 From: Matthew Leeds Date: Wed, 13 Nov 2019 18:30:58 -0800 Subject: [PATCH] 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. --- src/libostree/ostree-repo-pull.c | 3 ++- tests/test-pull-collections.sh | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c index 381cce47..a0f6db02 100644 --- a/src/libostree/ostree-repo-pull.c +++ b/src/libostree/ostree-repo-pull.c @@ -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 = pull_data->repo->disable_fsync ? GLNX_FILE_REPLACE_NODATASYNC : 0; diff --git a/tests/test-pull-collections.sh b/tests/test-pull-collections.sh index d1de5f88..cd60ab21 100755 --- a/tests/test-pull-collections.sh +++ b/tests/test-pull-collections.sh @@ -23,7 +23,7 @@ set -euo pipefail . $(dirname $0)/libtest.sh -echo '1..6' +echo '1..7' cd ${test_tmpdir} @@ -258,3 +258,15 @@ then fi 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"