mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-15 15:44:26 -04:00
move db checks under check_db if statement
This commit is contained in:
parent
74a9dd8880
commit
e3b69c450c
1 changed files with 11 additions and 10 deletions
|
@ -1079,6 +1079,16 @@ def setup_django(out_dir: Path=None, check_db=False, config: ConfigDict=CONFIG,
|
||||||
else:
|
else:
|
||||||
django.setup()
|
django.setup()
|
||||||
|
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
# log startup message to the error log
|
||||||
|
with open(settings.ERROR_LOG, "a+") as f:
|
||||||
|
command = ' '.join(sys.argv)
|
||||||
|
ts = datetime.now().strftime('%Y-%m-%d__%H:%M:%S')
|
||||||
|
f.write(f"\n> {command}; ts={ts} version={config['VERSION']} docker={config['IN_DOCKER']} is_tty={config['IS_TTY']}\n")
|
||||||
|
|
||||||
|
if check_db:
|
||||||
# Enable WAL mode in sqlite3
|
# Enable WAL mode in sqlite3
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
|
@ -1092,16 +1102,7 @@ def setup_django(out_dir: Path=None, check_db=False, config: ConfigDict=CONFIG,
|
||||||
cache.get('test', None)
|
cache.get('test', None)
|
||||||
except django.db.utils.OperationalError:
|
except django.db.utils.OperationalError:
|
||||||
call_command("createcachetable", verbosity=0)
|
call_command("createcachetable", verbosity=0)
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
# log startup message to the error log
|
|
||||||
with open(settings.ERROR_LOG, "a+") as f:
|
|
||||||
command = ' '.join(sys.argv)
|
|
||||||
ts = datetime.now().strftime('%Y-%m-%d__%H:%M:%S')
|
|
||||||
f.write(f"\n> {command}; ts={ts} version={config['VERSION']} docker={config['IN_DOCKER']} is_tty={config['IS_TTY']}\n")
|
|
||||||
|
|
||||||
if check_db:
|
|
||||||
sql_index_path = Path(output_dir) / SQL_INDEX_FILENAME
|
sql_index_path = Path(output_dir) / SQL_INDEX_FILENAME
|
||||||
assert sql_index_path.exists(), (
|
assert sql_index_path.exists(), (
|
||||||
f'No database file {SQL_INDEX_FILENAME} found in: {config["OUTPUT_DIR"]} (Are you in an ArchiveBox collection directory?)')
|
f'No database file {SQL_INDEX_FILENAME} found in: {config["OUTPUT_DIR"]} (Are you in an ArchiveBox collection directory?)')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue