1
0
Fork 0
mirror of synced 2024-06-26 10:00:19 +12:00

move db checks under check_db if statement

This commit is contained in:
Nick Sweeting 2021-02-18 02:37:33 -05:00
parent 74a9dd8880
commit e3b69c450c

View file

@ -1079,6 +1079,16 @@ def setup_django(out_dir: Path=None, check_db=False, config: ConfigDict=CONFIG,
else:
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
from django.db import connection
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)
except django.db.utils.OperationalError:
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
assert sql_index_path.exists(), (
f'No database file {SQL_INDEX_FILENAME} found in: {config["OUTPUT_DIR"]} (Are you in an ArchiveBox collection directory?)')