1
0
Fork 0

ensure correct permissions for output folder

This commit is contained in:
apkallum 2020-07-22 17:41:43 -04:00
parent 0aa3ee06a9
commit 0ed2a23670
3 changed files with 6 additions and 2 deletions

View File

@ -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)

View File

@ -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))

View File

@ -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: