mirror of https://github.com/borgbackup/borg.git
use version 2 for new archives
but still be able to read v1 archives for borg transfer.
This commit is contained in:
parent
e5f1a4fb4d
commit
d3dfa3be30
|
@ -472,7 +472,7 @@ class Archive:
|
|||
def _load_meta(self, id):
|
||||
data = self.key.decrypt(id, self.repository.get(id))
|
||||
metadata = ArchiveItem(internal_dict=msgpack.unpackb(data))
|
||||
if metadata.version != 1:
|
||||
if metadata.version not in (1, 2): # legacy: still need to read v1 archives
|
||||
raise Exception('Unknown archive metadata version')
|
||||
return metadata
|
||||
|
||||
|
@ -601,7 +601,7 @@ Utilization of max. archive size: {csize_max:.0%}
|
|||
self.start = start
|
||||
self.end = end
|
||||
metadata = {
|
||||
'version': 1,
|
||||
'version': 2,
|
||||
'name': name,
|
||||
'comment': comment or '',
|
||||
'items': self.items_buffer.chunks,
|
||||
|
@ -1748,7 +1748,7 @@ class ArchiveChecker:
|
|||
continue
|
||||
if not valid_msgpacked_dict(data, archive_keys_serialized):
|
||||
continue
|
||||
if b'cmdline' not in data or b'\xa7version\x01' not in data:
|
||||
if b'cmdline' not in data or b'\xa7version\x02' not in data:
|
||||
continue
|
||||
try:
|
||||
archive = msgpack.unpackb(data)
|
||||
|
@ -1989,7 +1989,7 @@ class ArchiveChecker:
|
|||
del self.manifest.archives[info.name]
|
||||
continue
|
||||
archive = ArchiveItem(internal_dict=msgpack.unpackb(data))
|
||||
if archive.version != 1:
|
||||
if archive.version != 2:
|
||||
raise Exception('Unknown archive metadata version')
|
||||
archive.cmdline = [safe_decode(arg) for arg in archive.cmdline]
|
||||
items_buffer = ChunkBuffer(self.key)
|
||||
|
|
|
@ -757,7 +757,7 @@ class LocalCache(CacheStatsMixin):
|
|||
csize, data = decrypted_repository.get(archive_id)
|
||||
chunk_idx.add(archive_id, 1, len(data), csize)
|
||||
archive = ArchiveItem(internal_dict=msgpack.unpackb(data))
|
||||
if archive.version != 1:
|
||||
if archive.version not in (1, 2): # legacy
|
||||
raise Exception('Unknown archive metadata version')
|
||||
sync = CacheSynchronizer(chunk_idx)
|
||||
for item_id, (csize, data) in zip(archive.items, decrypted_repository.get_many(archive.items)):
|
||||
|
|
|
@ -3873,7 +3873,7 @@ class ArchiverCheckTestCase(ArchiverTestCaseBase):
|
|||
'username': 'bar',
|
||||
'name': 'archive1',
|
||||
'time': '2016-12-15T18:49:51.849711',
|
||||
'version': 1,
|
||||
'version': 2,
|
||||
})
|
||||
archive_id = key.id_hash(archive)
|
||||
repository.put(archive_id, key.encrypt(archive_id, archive))
|
||||
|
|
Loading…
Reference in New Issue