Procházet zdrojové kódy

Repository: Read v2 hints files

Fixes #1235
Marian Beermann před 9 roky
rodič
revize
e7740458cd
1 změnil soubory, kde provedl 6 přidání a 2 odebrání
  1. 6 2
      borg/repository.py

+ 6 - 2
borg/repository.py

@@ -219,10 +219,14 @@ class Repository:
                 self.io.cleanup(transaction_id)
                 self.io.cleanup(transaction_id)
             with open(os.path.join(self.path, 'hints.%d' % transaction_id), 'rb') as fd:
             with open(os.path.join(self.path, 'hints.%d' % transaction_id), 'rb') as fd:
                 hints = msgpack.unpack(fd)
                 hints = msgpack.unpack(fd)
-            if hints[b'version'] != 1:
+            hints_version = hints[b'version']
+            if hints_version not in (1, 2):
                 raise ValueError('Unknown hints file version: %d' % hints['version'])
                 raise ValueError('Unknown hints file version: %d' % hints['version'])
             self.segments = hints[b'segments']
             self.segments = hints[b'segments']
-            self.compact = set(hints[b'compact'])
+            if hints_version == 1:
+                self.compact = set(hints[b'compact'])
+            elif hints_version == 2:
+                self.compact = set(hints[b'compact'].keys())
 
 
     def write_index(self):
     def write_index(self):
         hints = {b'version': 1,
         hints = {b'version': 1,