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

Method do_debug_parse_obj

src/borg/archiver/debug_cmd.py:226–246  ·  view source on GitHub ↗

Parses a Borg object file into a metadata dict and data (decrypting, decompressing).

(self, args, repository, manifest)

Source from the content-addressed store, hash-verified

224
225 @with_repository(compatibility=Manifest.NO_OPERATION_CHECK)
226 def do_debug_parse_obj(self, args, repository, manifest):
227 """Parses a Borg object file into a metadata dict and data (decrypting, decompressing)."""
228
229 # get the object from id
230 hex_id = args.id
231 try:
232 id = hex_to_bin(hex_id, length=32)
233 except ValueError as err:
234 raise CommandError(f"object id {hex_id} is invalid [{str(err)}].")
235
236 with open(args.object_path, "rb") as f:
237 cdata = f.read()
238
239 repo_objs = manifest.repo_objs
240 meta, data = repo_objs.parse(id=id, cdata=cdata, ro_type=ROBJ_DONTCARE)
241
242 with open(args.json_path, "w") as f:
243 json.dump(meta, f)
244
245 with open(args.binary_path, "wb") as f:
246 f.write(data)
247
248 @with_repository(compatibility=Manifest.NO_OPERATION_CHECK)
249 def do_debug_format_obj(self, args, repository, manifest):

Callers

nothing calls this directly

Calls 5

hex_to_binFunction · 0.85
CommandErrorClass · 0.85
readMethod · 0.45
parseMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected