From 86380a1ef2c028f5074c4fcc03a8ef60423e26a0 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Mon, 14 Oct 2024 17:35:43 -0700 Subject: [PATCH] fix .archivebox_id being created outside collection dir --- archivebox/config/paths.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/archivebox/config/paths.py b/archivebox/config/paths.py index 217dfbe9..12864f7c 100644 --- a/archivebox/config/paths.py +++ b/archivebox/config/paths.py @@ -41,7 +41,8 @@ def _get_collection_id(DATA_DIR=DATA_DIR, force_create=False) -> str: try: # only persist collection_id file if we already have an index.sqlite3 file present # otherwise we might be running in a directory that is not a collection, no point creating cruft files - if os.path.isfile(DATABASE_FILE) and os.access(DATA_DIR, os.W_OK) or force_create: + collection_is_active = os.path.isfile(DATABASE_FILE) and os.path.isdir(ARCHIVE_DIR) and os.access(DATA_DIR, os.W_OK) + if collection_is_active or force_create: collection_id_file.write_text(collection_id) # if we're running as root right now, make sure the collection_id file is owned by the archivebox user