1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-23 16:26:29 +00:00

borg mount: support --consider-part-files correctly, fixes #3347

This commit is contained in:
Thomas Waldmann 2017-11-22 15:08:08 +01:00
parent e97deafb16
commit caece370b8

View file

@ -119,7 +119,7 @@ def get(self, inode):
else: else:
raise ValueError('Invalid entry type in self.meta') raise ValueError('Invalid entry type in self.meta')
def iter_archive_items(self, archive_item_ids, filter=None): def iter_archive_items(self, archive_item_ids, filter=None, consider_part_files=False):
unpacker = msgpack.Unpacker() unpacker = msgpack.Unpacker()
# Current offset in the metadata stream, which consists of all metadata chunks glued together # Current offset in the metadata stream, which consists of all metadata chunks glued together
@ -163,7 +163,7 @@ def write_bytes(append_msgpacked_bytes):
break break
item = Item(internal_dict=item) item = Item(internal_dict=item)
if filter and not filter(item): if filter and not filter(item) or not consider_part_files and 'part' in item:
msgpacked_bytes = b'' msgpacked_bytes = b''
continue continue
@ -306,7 +306,8 @@ def peek_and_store_hardlink_masters(item, matched):
hardlink_masters[item.get('path')] = (item.get('chunks'), None) hardlink_masters[item.get('path')] = (item.get('chunks'), None)
filter = Archiver.build_filter(matcher, peek_and_store_hardlink_masters, strip_components) filter = Archiver.build_filter(matcher, peek_and_store_hardlink_masters, strip_components)
for item_inode, item in self.cache.iter_archive_items(archive.metadata.items, filter=filter): for item_inode, item in self.cache.iter_archive_items(archive.metadata.items, filter=filter,
consider_part_files=self._args.consider_part_files):
if strip_components: if strip_components:
item.path = os.sep.join(item.path.split(os.sep)[strip_components:]) item.path = os.sep.join(item.path.split(os.sep)[strip_components:])
path = os.fsencode(item.path) path = os.fsencode(item.path)