Don't copy summary for collection-ref mirror subset pulls
authorMatthew Leeds <matthew.leeds@endlessm.com>
Thu, 14 Nov 2019 02:30:58 +0000 (18:30 -0800)
committerMatthew Leeds <matthew.leeds@endlessm.com>
Sat, 28 Mar 2020 17:35:19 +0000 (10:35 -0700)
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
tests/test-pull-collections.sh

index 381cce479cc7ea06dd5bb7d647b5dcbca6ebda1d..a0f6db02a085121d34b791b85f955b48215fdd5f 100644 (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 =
         pull_data->repo->disable_fsync ? GLNX_FILE_REPLACE_NODATASYNC : 0;
index d1de5f88f9acf50f4e5455e315a23996c1c61051..cd60ab21e9f265430fd076fd7bf357d82f174d92 100755 (executable)
@@ -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"