Merge pull request #391 from apkallum/origin/archived-item-permissions
ensure correct permissions for archived items
This commit is contained in:
commit
74ad79f1fc
2 changed files with 13 additions and 2 deletions
|
@ -53,8 +53,11 @@ def chmod_file(path: str, cwd: str='.', permissions: str=OUTPUT_PERMISSIONS) ->
|
||||||
if not root.exists():
|
if not root.exists():
|
||||||
raise Exception('Failed to chmod: {} does not exist (did the previous step fail?)'.format(path))
|
raise Exception('Failed to chmod: {} does not exist (did the previous step fail?)'.format(path))
|
||||||
|
|
||||||
for subpath in Path(path).glob('**/*'):
|
if not root.is_dir():
|
||||||
os.chmod(subpath, int(OUTPUT_PERMISSIONS, base=8))
|
os.chmod(root, int(OUTPUT_PERMISSIONS, base=8))
|
||||||
|
else:
|
||||||
|
for subpath in Path(path).glob('**/*'):
|
||||||
|
os.chmod(subpath, int(OUTPUT_PERMISSIONS, base=8))
|
||||||
|
|
||||||
|
|
||||||
@enforce_types
|
@enforce_types
|
||||||
|
|
|
@ -51,3 +51,11 @@ def test_correct_permissions_output_folder(tmp_path, process):
|
||||||
file_path = tmp_path / file
|
file_path = tmp_path / file
|
||||||
assert oct(file_path.stat().st_mode)[-3:] == OUTPUT_PERMISSIONS
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue