pull: When mirroring, only replace summary if we're doing a full mirror
authorAlexander Larsson <alexl@redhat.com>
Fri, 16 Jun 2017 08:07:44 +0000 (10:07 +0200)
committerAtomic Bot <atomic-devel@projectatomic.io>
Fri, 16 Jun 2017 15:08:39 +0000 (15:08 +0000)
We're hitting this in flathub, where we have a bunch of local builds,
but we also mirror a few refs from the gnome runtime repo into it.
Its fixable by re-doing the summary, but for a short time the
wrong version is visible.

Fixes https://github.com/ostreedev/ostree/issues/846

Closes: #935
Approved by: cgwalters

src/libostree/ostree-repo-pull.c
tests/pull-test.sh

index 704a68d22fc954a822bee19772fa6b7cc682e5fb..2c87fd6090d868c1aff7f7a3fd0c789b447bc6fb 100644 (file)
@@ -3518,7 +3518,7 @@ ostree_repo_pull_with_options (OstreeRepo             *self,
         }
     }
 
-  if (pull_data->is_mirror && pull_data->summary_data)
+  if (pull_data->is_mirror && pull_data->summary_data && !refs_to_fetch && !configured_branches)
     {
       GLnxFileReplaceFlags replaceflag =
         pull_data->repo->disable_fsync ? GLNX_FILE_REPLACE_NODATASYNC : 0;
index 9f74c0d8c0285c5605c71e658192203b66066435..24eb16a08c54179438249e263adabe172d841757 100644 (file)
@@ -35,7 +35,7 @@ function verify_initial_contents() {
     assert_file_has_content baz/cow '^moo$'
 }
 
-echo "1..23"
+echo "1..25"
 
 # Try both syntaxes
 repo_init --no-gpg-verify
@@ -57,6 +57,33 @@ ${CMD_PREFIX} ostree --repo=mirrorrepo fsck
 $OSTREE show main >/dev/null
 echo "ok pull mirror"
 
+mkdir otherbranch
+echo someothercontent > otherbranch/someothercontent
+${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo commit -b otherbranch --tree=dir=otherbranch
+${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo summary -u
+rm mirrorrepo -rf
+# All refs
+ostree_repo_init mirrorrepo --mode=archive-z2
+${CMD_PREFIX} ostree --repo=mirrorrepo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
+${CMD_PREFIX} ostree --repo=mirrorrepo pull --mirror origin
+${CMD_PREFIX} ostree --repo=mirrorrepo fsck
+for ref in main otherbranch; do
+    ${CMD_PREFIX} ostree --repo=mirrorrepo rev-parse $ref
+done
+echo "ok pull mirror (all refs)"
+
+rm mirrorrepo -rf
+ostree_repo_init mirrorrepo --mode=archive-z2
+${CMD_PREFIX} ostree --repo=mirrorrepo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
+# Generate a summary in the mirror
+${CMD_PREFIX} ostree --repo=mirrorrepo summary -u
+summarysig=$(sha256sum < mirrorrepo/summary | cut -f 1 -d ' ')
+# Mirror subset of refs: https://github.com/ostreedev/ostree/issues/846
+${CMD_PREFIX} ostree --repo=mirrorrepo pull --mirror origin main
+newsummarysig=$(sha256sum < mirrorrepo/summary | cut -f 1 -d ' ')
+assert_streq ${summarysig} ${newsummarysig}
+echo "ok pull mirror (ref subset with summary)"
+
 cd ${test_tmpdir}
 rm checkout-origin-main -rf
 $OSTREE --repo=ostree-srv/gnomerepo checkout main checkout-origin-main