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

Method get

src/borg/fuse.py:154–176  ·  view source on GitHub ↗
(self, inode)

Source from the content-addressed store, hash-verified

152 self.direct_items = 0
153
154 def get(self, inode):
155 offset = inode - self.offset
156 if offset < 0:
157 raise ValueError("ItemCache.get() called with an invalid inode number")
158 if self.meta[offset] == ord(b"I"):
159 _, chunk_id_relative_offset, chunk_offset = self.indirect_entry_struct.unpack_from(self.meta, offset)
160 chunk_id_offset = offset - chunk_id_relative_offset
161 # bytearray slices are bytearrays as well, explicitly convert to bytes()
162 chunk_id = bytes(self.meta[chunk_id_offset : chunk_id_offset + 32])
163 chunk = self.chunks.get(chunk_id)
164 if not chunk:
165 csize, chunk = next(self.decrypted_repository.get_many([chunk_id]))
166 self.chunks[chunk_id] = chunk
167 data = memoryview(chunk)[chunk_offset:]
168 unpacker = msgpack.Unpacker()
169 unpacker.feed(data)
170 return Item(internal_dict=next(unpacker))
171 elif self.meta[offset] == ord(b"S"):
172 fd_offset = int.from_bytes(self.meta[offset + 1 : offset + 9], "little")
173 self.fd.seek(fd_offset, io.SEEK_SET)
174 return Item(internal_dict=next(msgpack.Unpacker(self.fd, read_size=1024)))
175 else:
176 raise ValueError("Invalid entry type in self.meta")
177
178 def iter_archive_items(self, archive_item_ids, filter=None):
179 unpacker = msgpack.Unpacker()

Callers 15

setup.pyFile · 0.45
lib_ext_kwargsFunction · 0.45
xattr.pyFile · 0.45
fuse_impl.pyFile · 0.45
files_cache_nameFunction · 0.45
loadMethod · 0.45
_build_files_cacheMethod · 0.45
_read_files_cacheMethod · 0.45
_write_files_cacheMethod · 0.45
seen_chunkMethod · 0.45
get_childMethod · 0.45

Calls 3

feedMethod · 0.80
get_manyMethod · 0.45
seekMethod · 0.45

Tested by 1

selftestFunction · 0.36