Formats file and metadata into a Borg object file.
(self, args, repository, manifest)
| 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): |
nothing calls this directly
no test coverage detected