فهرست منبع

Merge pull request #2660 from enkore/issue/2659

cache sync: check Operation.READ compatibility with manifest
enkore 8 سال پیش
والد
کامیت
5eeaf7a67c
2فایلهای تغییر یافته به همراه11 افزوده شده و 0 حذف شده
  1. 5 0
      src/borg/cache.py
  2. 6 0
      src/borg/testsuite/archiver.py

+ 5 - 0
src/borg/cache.py

@@ -721,6 +721,11 @@ Chunk index:    {0.total_unique_chunks:20d} {0.total_chunks:20d}"""
             except:
             except:
                 pass
                 pass
 
 
+        # The cache can be used by a command that e.g. only checks against Manifest.Operation.WRITE,
+        # which does not have to include all flags from Manifest.Operation.READ.
+        # Since the sync will attempt to read archives, check compatibility with Manifest.Operation.READ.
+        self.manifest.check_repository_compatibility((Manifest.Operation.READ, ))
+
         self.begin_txn()
         self.begin_txn()
         with cache_if_remote(self.repository, decrypted_cache=self.key) as decrypted_repository:
         with cache_if_remote(self.repository, decrypted_cache=self.key) as decrypted_repository:
             legacy_cleanup()
             legacy_cleanup()

+ 6 - 0
src/borg/testsuite/archiver.py

@@ -1440,6 +1440,12 @@ class ArchiverTestCase(ArchiverTestCaseBase):
         self.add_unknown_feature(Manifest.Operation.WRITE)
         self.add_unknown_feature(Manifest.Operation.WRITE)
         self.cmd_raises_unknown_feature(['create', self.repository_location + '::test', 'input'])
         self.cmd_raises_unknown_feature(['create', self.repository_location + '::test', 'input'])
 
 
+    def test_unknown_feature_on_cache_sync(self):
+        self.cmd('init', '--encryption=repokey', self.repository_location)
+        self.cmd('delete', '--cache-only', self.repository_location)
+        self.add_unknown_feature(Manifest.Operation.READ)
+        self.cmd_raises_unknown_feature(['create', self.repository_location + '::test', 'input'])
+
     def test_unknown_feature_on_change_passphrase(self):
     def test_unknown_feature_on_change_passphrase(self):
         print(self.cmd('init', '--encryption=repokey', self.repository_location))
         print(self.cmd('init', '--encryption=repokey', self.repository_location))
         self.add_unknown_feature(Manifest.Operation.CHECK)
         self.add_unknown_feature(Manifest.Operation.CHECK)