mirror of
https://github.com/ArchiveBox/ArchiveBox
synced 2024-11-10 06:34:16 +00:00
ensure correct permissions for output folder
This commit is contained in:
parent
0aa3ee06a9
commit
0ed2a23670
3 changed files with 6 additions and 2 deletions
|
@ -26,6 +26,7 @@ from ..config import (
|
|||
URL_BLACKLIST_PTN,
|
||||
ANSI,
|
||||
stderr,
|
||||
OUTPUT_PERMISSIONS
|
||||
)
|
||||
from ..logging_util import (
|
||||
TimedProgress,
|
||||
|
@ -232,6 +233,8 @@ def write_main_index(links: List[Link], out_dir: str=OUTPUT_DIR, finished: bool=
|
|||
|
||||
with timed_index_update(os.path.join(out_dir, SQL_INDEX_FILENAME)):
|
||||
write_sql_main_index(links, out_dir=out_dir)
|
||||
os.chmod(os.path.join(out_dir, SQL_INDEX_FILENAME), int(OUTPUT_PERMISSIONS, base=8)) # set here because we don't write it with atomic writes
|
||||
|
||||
|
||||
with timed_index_update(os.path.join(out_dir, JSON_INDEX_FILENAME)):
|
||||
write_json_main_index(links, out_dir=out_dir)
|
||||
|
|
|
@ -87,6 +87,7 @@ from .config import (
|
|||
CONFIG,
|
||||
USER_CONFIG,
|
||||
get_real_name,
|
||||
OUTPUT_PERMISSIONS
|
||||
)
|
||||
from .logging_util import (
|
||||
TERM_WIDTH,
|
||||
|
@ -240,8 +241,8 @@ def run(subcommand: str,
|
|||
@enforce_types
|
||||
def init(force: bool=False, out_dir: str=OUTPUT_DIR) -> None:
|
||||
"""Initialize a new ArchiveBox collection in the current directory"""
|
||||
os.umask(0o777 - int(OUTPUT_PERMISSIONS, base=8))
|
||||
os.makedirs(out_dir, exist_ok=True)
|
||||
|
||||
is_empty = not len(set(os.listdir(out_dir)) - ALLOWED_IN_OUTPUT_DIR)
|
||||
existing_index = os.path.exists(os.path.join(out_dir, JSON_INDEX_FILENAME))
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ def atomic_write(path: Union[Path, str], contents: Union[dict, str, bytes], over
|
|||
dump(contents, f, indent=4, sort_keys=True, cls=ExtendedEncoder)
|
||||
elif isinstance(contents, (bytes, str)):
|
||||
f.write(contents)
|
||||
|
||||
os.chmod(path, int(OUTPUT_PERMISSIONS, base=8))
|
||||
|
||||
@enforce_types
|
||||
def chmod_file(path: str, cwd: str='.', permissions: str=OUTPUT_PERMISSIONS) -> None:
|
||||
|
|
Loading…
Reference in a new issue