Browse Source

Merge pull request #1255 from enkore/issue/1235

Repository: Read v2 hints files
enkore 9 years ago
parent
commit
c9597406ba
1 changed files with 7 additions and 3 deletions
  1. 7 3
      borg/repository.py

+ 7 - 3
borg/repository.py

@@ -219,10 +219,14 @@ class Repository:
                 self.io.cleanup(transaction_id)
             with open(os.path.join(self.path, 'hints.%d' % transaction_id), 'rb') as fd:
                 hints = msgpack.unpack(fd)
-            if hints[b'version'] != 1:
-                raise ValueError('Unknown hints file version: %d' % hints['version'])
+            hints_version = hints[b'version']
+            if hints_version not in (1, 2):
+                raise ValueError('Unknown hints file version: %d' % hints_version)
             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):
         hints = {b'version': 1,