소스 검색

cache sync: fetch_missing_csize don't check ids against empty idx

This is always the case if self.do_cache is False.
Marian Beermann 8 년 전
부모
커밋
3c8257432a
2개의 변경된 파일14개의 추가작업 그리고 8개의 파일을 삭제
  1. 11 8
      src/borg/cache.py
  2. 3 0
      src/borg/testsuite/archiver.py

+ 11 - 8
src/borg/cache.py

@@ -644,14 +644,17 @@ class LocalCache(CacheStatsMixin):
 
             all_missing_ids = chunk_idx.zero_csize_ids()
             fetch_ids = []
-            for id_ in all_missing_ids:
-                already_fetched_entry = chunks_fetched_size_index.get(id_)
-                if already_fetched_entry:
-                    entry = chunk_idx[id_]._replace(csize=already_fetched_entry.csize)
-                    assert entry.size == already_fetched_entry.size, 'Chunk size mismatch'
-                    chunk_idx[id_] = entry
-                else:
-                    fetch_ids.append(id_)
+            if len(chunks_fetched_size_index):
+                for id_ in all_missing_ids:
+                    already_fetched_entry = chunks_fetched_size_index.get(id_)
+                    if already_fetched_entry:
+                        entry = chunk_idx[id_]._replace(csize=already_fetched_entry.csize)
+                        assert entry.size == already_fetched_entry.size, 'Chunk size mismatch'
+                        chunk_idx[id_] = entry
+                    else:
+                        fetch_ids.append(id_)
+            else:
+                fetch_ids = all_missing_ids
 
             for id_, data in zip(fetch_ids, decrypted_repository.repository.get_many(fetch_ids)):
                 entry = chunk_idx[id_]._replace(csize=len(data))

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

@@ -1041,6 +1041,9 @@ class ArchiverTestCase(ArchiverTestCaseBase):
         create_stats = create_json['cache']['stats']
         info_stats = info_json['cache']['stats']
         assert create_stats == info_stats
+        self.cmd('delete', '--cache-only', self.repository_location)
+        self.cmd('create', '--no-cache-sync', self.repository_location + '::test2', 'input')
+        self.cmd('info', self.repository_location)
         self.cmd('check', self.repository_location)
 
     def test_extract_pattern_opt(self):