From 9cb0be183b00d8c63f23b920cfa5a6e5a5c23365 Mon Sep 17 00:00:00 2001 From: apkallum Date: Fri, 24 Jul 2020 14:02:11 -0400 Subject: [PATCH 1/2] ensure correct permissions for archived items --- archivebox/system.py | 8 ++++++-- tests/test_init.py | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/archivebox/system.py b/archivebox/system.py index a9b3758b..f7d95d49 100644 --- a/archivebox/system.py +++ b/archivebox/system.py @@ -53,8 +53,12 @@ def chmod_file(path: str, cwd: str='.', permissions: str=OUTPUT_PERMISSIONS) -> if not root.exists(): raise Exception('Failed to chmod: {} does not exist (did the previous step fail?)'.format(path)) - for subpath in Path(path).glob('**/*'): - os.chmod(subpath, int(OUTPUT_PERMISSIONS, base=8)) + if not root.is_dir(): + os.chmod(root, int(OUTPUT_PERMISSIONS, base=8)) + else: + for subpath in Path(path).glob('**/*'): + print("THE PATH TO MODIFY IS", subpath) + os.chmod(subpath, int(OUTPUT_PERMISSIONS, base=8)) @enforce_types diff --git a/tests/test_init.py b/tests/test_init.py index 0b2832c3..133aaaa9 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -51,3 +51,11 @@ def test_correct_permissions_output_folder(tmp_path, process): file_path = tmp_path / file assert oct(file_path.stat().st_mode)[-3:] == OUTPUT_PERMISSIONS +def test_correct_permissions_add_command_results(tmp_path, process): + os.chdir(tmp_path) + add_process = subprocess.run(['archivebox', 'add', 'http://127.0.0.1:8080/static/example.com.html'], capture_output=True) + archived_item_path = list(tmp_path.glob('archive/**/*'))[0] + for path in archived_item_path.iterdir(): + assert oct(path.stat().st_mode)[-3:] == OUTPUT_PERMISSIONS + + From fa17e20f8e8a3c334425c82fe8045ba6d9096a41 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Fri, 24 Jul 2020 14:33:06 -0400 Subject: [PATCH 2/2] Update archivebox/system.py --- archivebox/system.py | 1 - 1 file changed, 1 deletion(-) diff --git a/archivebox/system.py b/archivebox/system.py index f7d95d49..533dadc6 100644 --- a/archivebox/system.py +++ b/archivebox/system.py @@ -57,7 +57,6 @@ def chmod_file(path: str, cwd: str='.', permissions: str=OUTPUT_PERMISSIONS) -> os.chmod(root, int(OUTPUT_PERMISSIONS, base=8)) else: for subpath in Path(path).glob('**/*'): - print("THE PATH TO MODIFY IS", subpath) os.chmod(subpath, int(OUTPUT_PERMISSIONS, base=8))