SKIP IHDR and Clear at restart
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
MAX_CONTENT_LENGTH=1048576
|
MAX_CONTENT_LENGTH=1048576
|
||||||
MAX_PENDING_TIME=600
|
MAX_PENDING_TIME=600
|
||||||
MAX_STORE_TIME=259200
|
MAX_STORE_TIME=259200
|
||||||
|
CLEAR_AT_RESTART=1
|
||||||
|
SKIP_IHDR_FILL=1
|
||||||
|
|
||||||
# Flask configuration
|
# Flask configuration
|
||||||
FLASK_DEBUG=0
|
FLASK_DEBUG=0
|
||||||
|
|||||||
+14
-4
@@ -5,6 +5,9 @@
|
|||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
|
from os import getenv
|
||||||
|
from pathlib import Path
|
||||||
|
from shutil import rmtree
|
||||||
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
@@ -128,9 +131,16 @@ def init_db(app: Flask) -> None:
|
|||||||
"""
|
"""
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
if not db.engine.dialect.has_table(db.engine.connect(), "image"):
|
if not db.engine.dialect.has_table(db.engine.connect(), "image"):
|
||||||
print("Creating database...")
|
print(f"CLEAR_AT_RESTART={getenv('CLEAR_AT_RESTART', '0')}")
|
||||||
|
if getenv("CLEAR_AT_RESTART", "0") == "1":
|
||||||
|
print("Clearing database and file system at restart...")
|
||||||
|
db.drop_all() # Clear existing tables if configured
|
||||||
|
rmtree(Path("./results"), ignore_errors=True) # Clear results folder
|
||||||
db.create_all()
|
db.create_all()
|
||||||
print("Database structure created successfully.")
|
print("Database structure created successfully.")
|
||||||
print("Filling IHDR lookup table...")
|
if getenv("SKIP_IHDR_FILL", "0") == "1":
|
||||||
create_crc_db()
|
print("Skipping IHDR lookup table fill as per configuration.")
|
||||||
print("IHDR table filled successfully.")
|
else:
|
||||||
|
print("Filling IHDR lookup table...")
|
||||||
|
create_crc_db()
|
||||||
|
print("IHDR table filled successfully.")
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- FLASK_DEBUG=true
|
- FLASK_DEBUG=true
|
||||||
- FLASK_ENV=development
|
- FLASK_ENV=development
|
||||||
|
- SKIP_IHDR_FILL=1
|
||||||
|
|
||||||
worker:
|
worker:
|
||||||
#image: ghcr.io/zeecka/aperisolve:latest
|
#image: ghcr.io/zeecka/aperisolve:latest
|
||||||
|
|||||||
Reference in New Issue
Block a user