From 0c29e08f7363a00bc6abdd4827344cdb113489a1 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Wed, 9 Oct 2024 19:12:08 -0700 Subject: [PATCH] avoid creating collection id file on every startup since its not needed --- archivebox/config/legacy.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/archivebox/config/legacy.py b/archivebox/config/legacy.py index 16231553..f53a9b29 100644 --- a/archivebox/config/legacy.py +++ b/archivebox/config/legacy.py @@ -572,15 +572,13 @@ def setup_django(out_dir: Path | None=None, check_db=False, config: benedict=CON assert isinstance(output_dir, Path) and isinstance(CONSTANTS.PACKAGE_DIR, Path) from archivebox.config.permissions import IS_ROOT, ARCHIVEBOX_USER, ARCHIVEBOX_GROUP, SudoPermission - from archivebox.config.paths import _get_collection_id # if running as root, chown the data dir to the archivebox user to make sure it's accessible to the archivebox user - if IS_ROOT: + if IS_ROOT and ARCHIVEBOX_USER != 0: with SudoPermission(uid=0): + # running as root is a special case where it's ok to be a bit slower + # make sure data dir is always owned by the correct user os.system(f'chown {ARCHIVEBOX_USER}:{ARCHIVEBOX_GROUP} "{CONSTANTS.DATA_DIR}"') - _get_collection_id(DATA_DIR=CONSTANTS.DATA_DIR, force_create=True) - if IS_ROOT: - with SudoPermission(uid=0): os.system(f'chown {ARCHIVEBOX_USER}:{ARCHIVEBOX_GROUP} "{CONSTANTS.DATA_DIR}"/* 2>/dev/null') bump_startup_progress_bar()