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

Method do_debug_format_obj

src/borg/archiver/debug_cmd.py:249–270  ·  view source on GitHub ↗

Formats file and metadata into a Borg object file.

(self, args, repository, manifest)

Source from the content-addressed store, hash-verified

247
248 @with_repository(compatibility=Manifest.NO_OPERATION_CHECK)
249 def do_debug_format_obj(self, args, repository, manifest):
250 """Formats file and metadata into a Borg object file."""
251
252 # get the object from id
253 hex_id = args.id
254 try:
255 id = hex_to_bin(hex_id, length=32)
256 except ValueError as err:
257 raise CommandError(f"object id {hex_id} is invalid [{str(err)}].")
258
259 with open(args.binary_path, "rb") as f:
260 data = f.read()
261
262 with open(args.json_path) as f:
263 meta = json.load(f)
264
265 repo_objs = manifest.repo_objs
266 ro_type = meta.pop("type", ROBJ_FILE_STREAM)
267 data_encrypted = repo_objs.format(id=id, meta=meta, data=data, ro_type=ro_type)
268
269 with open(args.object_path, "wb") as f:
270 f.write(data_encrypted)
271
272 @with_repository(manifest=False)
273 def do_debug_put_obj(self, args, repository):

Callers

nothing calls this directly

Calls 6

hex_to_binFunction · 0.85
CommandErrorClass · 0.85
readMethod · 0.45
loadMethod · 0.45
formatMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected