From 9f1470cf03ecccd5ef980a3016263e623a1e9b3f Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Mon, 31 May 2021 20:57:46 -0400 Subject: [PATCH] fix output permissions tests --- archivebox/system.py | 6 +++--- tests/test_init.py | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/archivebox/system.py b/archivebox/system.py index 028fbe8f..09066fcf 100644 --- a/archivebox/system.py +++ b/archivebox/system.py @@ -118,15 +118,15 @@ def chmod_file(path: str, cwd: str='.', permissions: str=OUTPUT_PERMISSIONS) -> if not root.is_dir(): # path is just a plain file - os.chmod(root, int(OUTPUT_PERMISSIONS, base=8)) + os.chmod(root, int(permissions, base=8)) else: for subpath in Path(path).glob('**/*'): if subpath.is_dir(): # directories need execute permissions to be able to list contents - perms_with_x_allowed = OUTPUT_PERMISSIONS.replace('4', '5').replace('6', '7') + perms_with_x_allowed = permissions.replace('4', '5').replace('6', '7') os.chmod(subpath, int(perms_with_x_allowed, base=8)) else: - os.chmod(subpath, int(OUTPUT_PERMISSIONS, base=8)) + os.chmod(subpath, int(permissions, base=8)) @enforce_types diff --git a/tests/test_init.py b/tests/test_init.py index 728aedfb..156d1907 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -11,6 +11,8 @@ from archivebox.config import OUTPUT_PERMISSIONS from .fixtures import * +DIR_PERMISSIONS = OUTPUT_PERMISSIONS.replace('6', '7').replace('4', '5') + def test_init(tmp_path, process): assert "Initializing a new ArchiveBox" in process.stdout.decode("utf-8") @@ -55,7 +57,7 @@ def test_correct_permissions_output_folder(tmp_path, process): index_files = ['index.sqlite3', 'archive'] for file in index_files: file_path = tmp_path / file - assert oct(file_path.stat().st_mode)[-3:] == OUTPUT_PERMISSIONS + assert oct(file_path.stat().st_mode)[-3:] in (OUTPUT_PERMISSIONS, DIR_PERMISSIONS) def test_correct_permissions_add_command_results(tmp_path, process, disable_extractors_dict): os.chdir(tmp_path) @@ -63,7 +65,7 @@ def test_correct_permissions_add_command_results(tmp_path, process, disable_extr env=disable_extractors_dict) 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 + assert oct(path.stat().st_mode)[-3:] in (OUTPUT_PERMISSIONS, DIR_PERMISSIONS) def test_collision_urls_different_timestamps(tmp_path, process, disable_extractors_dict): os.chdir(tmp_path)