fix .archivebox_id being created outside collection dir

This commit is contained in:
Nick Sweeting 2024-10-14 17:35:43 -07:00
parent 9a04ed7c76
commit 86380a1ef2
No known key found for this signature in database

View file

@ -41,7 +41,8 @@ def _get_collection_id(DATA_DIR=DATA_DIR, force_create=False) -> str:
try: try:
# only persist collection_id file if we already have an index.sqlite3 file present # 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 # 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) 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 # if we're running as root right now, make sure the collection_id file is owned by the archivebox user