move tmp dir to machine-id scoped dir
Some checks are pending
CodeQL / Analyze (python) (push) Waiting to run
Build Debian package / build (push) Waiting to run
Build Docker image / buildx (push) Waiting to run
Build Homebrew package / build (push) Waiting to run
Build GitHub Pages website / build (push) Waiting to run
Build GitHub Pages website / deploy (push) Blocked by required conditions
Run linters / lint (push) Waiting to run
Build Pip package / build (push) Waiting to run
Run tests / python_tests (ubuntu-22.04, 3.11) (push) Waiting to run
Run tests / docker_tests (push) Waiting to run

This commit is contained in:
Nick Sweeting 2024-10-04 03:24:15 -07:00
parent 12f32c4690
commit 396a7ffcd8
No known key found for this signature in database
8 changed files with 42 additions and 26 deletions

View file

@ -1,12 +1,5 @@
#!/usr/bin/env python3
ASCII_LOGO = """
"""
# Welcome to the ArchiveBox source code! Thanks for checking it out!
#
# "We are swimming upstream against a great torrent of disorganization.
@ -23,14 +16,25 @@ import sys
import tempfile
from pathlib import Path
USING_TMP_DATA_DIR = None
ASCII_LOGO = """
"""
SYSTEM_TMP_DIR = Path(tempfile.gettempdir()) / 'archivebox'
SYSTEM_TMP_DIR.mkdir(parents=True, exist_ok=True)
os.environ['SYSTEM_TMP_DIR'] = str(SYSTEM_TMP_DIR)
# if we are outside a data dir, cd into an ephemeral tmp dir so that
# we can run version/help without polluting cwd with an index.sqlite3
if len(sys.argv) > 1 and sys.argv[1] in ('version', 'help'):
current_dir = Path(os.getcwd()).resolve()
if not (current_dir / 'index.sqlite3').exists():
USING_TMP_DATA_DIR = Path(tempfile.gettempdir()) / 'archivebox'
USING_TMP_DATA_DIR.mkdir(parents=True, exist_ok=True)
os.chdir(USING_TMP_DATA_DIR)
os.chdir(SYSTEM_TMP_DIR)
# make sure PACKAGE_DIR is in sys.path so we can import all subfolders
# without necessarily waiting for django to load them thorugh INSTALLED_APPS