Marco Ricci commited on 2024-08-18 00:14:59
Zeige 1 geänderte Dateien mit 13 Einfügungen und 4 Löschungen.
In the storeroom exporter, pass the storeroom directory explicitly, and open and glob all bucket files relative to this directory.
| ... | ... |
@@ -394,9 +394,14 @@ def decrypt_bucket_item(bucket_item: bytes, master_keys: MasterKeys) -> bytes: |
| 394 | 394 |
|
| 395 | 395 |
|
| 396 | 396 |
def decrypt_bucket_file( |
| 397 |
- filename: str, master_keys: MasterKeys |
|
| 397 |
+ filename: str, |
|
| 398 |
+ master_keys: MasterKeys, |
|
| 399 |
+ *, |
|
| 400 |
+ root_dir: str | bytes | os.PathLike = '.', |
|
| 398 | 401 |
) -> Iterator[bytes]: |
| 399 |
- with open(filename, 'rb') as bucket_file: |
|
| 402 |
+ with open( |
|
| 403 |
+ os.path.join(os.fsdecode(root_dir), filename), 'rb' |
|
| 404 |
+ ) as bucket_file: |
|
| 400 | 405 |
header_line = bucket_file.readline() |
| 401 | 406 |
try: |
| 402 | 407 |
header = json.loads(header_line) |
| ... | ... |
@@ -501,8 +506,12 @@ def export_storeroom_data( |
| 501 | 506 |
|
| 502 | 507 |
config_structure: dict[str, Any] = {}
|
| 503 | 508 |
json_contents: dict[str, bytes] = {}
|
| 504 |
- for file in glob.glob('[01][0-9a-f]'):
|
|
| 505 |
- bucket_contents = list(decrypt_bucket_file(file, master_keys)) |
|
| 509 |
+ for file in glob.glob( |
|
| 510 |
+ '[01][0-9a-f]', root_dir=os.fsdecode(storeroom_path) |
|
| 511 |
+ ): |
|
| 512 |
+ bucket_contents = list( |
|
| 513 |
+ decrypt_bucket_file(file, master_keys, root_dir=storeroom_path) |
|
| 514 |
+ ) |
|
| 506 | 515 |
bucket_index = json.loads(bucket_contents.pop(0)) |
| 507 | 516 |
for pos, item in enumerate(bucket_index): |
| 508 | 517 |
json_contents[item] = bucket_contents[pos] |
| 509 | 518 |