MCPcopy
hub / github.com/borgbackup/borg / _process_archive

Method _process_archive

src/borg/fuse.py:367–400  ·  view source on GitHub ↗

Build FUSE inode hierarchy from archive metadata

(self, archive_id, prefix=[])

Source from the content-addressed store, hash-verified

365 return inode
366
367 def _process_archive(self, archive_id, prefix=[]):
368 """Build FUSE inode hierarchy from archive metadata"""
369 self.file_versions = {} # for versions mode: original path -> version
370 t0 = time.perf_counter()
371 archive = Archive(self._manifest, archive_id)
372 strip_components = self._args.strip_components
373 # omitting args.pattern_roots here, restricting to paths only by cli args.paths:
374 matcher = build_matcher(self._args.patterns, self._args.paths)
375 hlm = HardLinkManager(id_type=bytes, info_type=str) # hlid -> path
376
377 filter = build_filter(matcher, strip_components)
378 for item_inode, item in self.cache.iter_archive_items(archive.metadata.items, filter=filter):
379 if strip_components:
380 item.path = os.sep.join(item.path.split(os.sep)[strip_components:])
381 path = os.fsencode(item.path)
382 is_dir = stat.S_ISDIR(item.mode)
383 if is_dir:
384 try:
385 # This can happen if an archive was created with a command line like
386 # $ borg create ... dir1/file dir1
387 # In this case the code below will have created a default_dir inode for dir1 already.
388 inode = self.find_inode(path, prefix)
389 except KeyError:
390 pass
391 else:
392 self._items[inode] = item
393 continue
394 segments = prefix + path.split(b"/")
395 parent = 1
396 for segment in segments[:-1]:
397 parent = self._process_inner(segment, parent)
398 self._process_leaf(segments[-1], item, parent, prefix, is_dir, item_inode, hlm)
399 duration = time.perf_counter() - t0
400 logger.debug("fuse: _process_archive completed in %.1f s for archive %s", duration, archive.name)
401
402 def _process_leaf(self, name, item, parent, prefix, is_dir, item_inode, hlm):
403 path = item.path

Callers 2

_create_filesystemMethod · 0.95
check_pending_archiveMethod · 0.95

Calls 9

find_inodeMethod · 0.95
_process_innerMethod · 0.95
_process_leafMethod · 0.95
ArchiveClass · 0.85
build_matcherFunction · 0.85
HardLinkManagerClass · 0.85
build_filterFunction · 0.85
iter_archive_itemsMethod · 0.80
debugMethod · 0.80

Tested by

no test coverage detected