Now working
This commit is contained in:
+3
-2
@@ -33,9 +33,10 @@ app.config["MAX_CONTENT_LENGTH"] = int(
|
|||||||
)
|
)
|
||||||
RESULT_FOLDER.mkdir(parents=True, exist_ok=True)
|
RESULT_FOLDER.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
|
||||||
db.init_app(app)
|
db.init_app(app)
|
||||||
init_db(app)
|
with app.app_context():
|
||||||
|
init_db(app)
|
||||||
|
|
||||||
redis_conn = Redis(host="redis", port=6379)
|
redis_conn = Redis(host="redis", port=6379)
|
||||||
queue = Queue(connection=redis_conn)
|
queue = Queue(connection=redis_conn)
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class IHDR(db.Model): # type: ignore
|
|||||||
packed = Column(BigInteger, nullable=False)
|
packed = Column(BigInteger, nullable=False)
|
||||||
|
|
||||||
|
|
||||||
def create_crc_db() -> None:
|
def fill_ihdr_db() -> None:
|
||||||
"""
|
"""
|
||||||
Creates a database of common PNG IHDR (Image Header) entries by generating
|
Creates a database of common PNG IHDR (Image Header) entries by generating
|
||||||
combinations of standard PNG parameters such as resolutions, bit depths,
|
combinations of standard PNG parameters such as resolutions, bit depths,
|
||||||
@@ -132,18 +132,16 @@ def init_db(app: Flask) -> None:
|
|||||||
with app.app_context():
|
with app.app_context():
|
||||||
if getenv("CLEAR_AT_RESTART", "0") == "1": # Force clear if CLEAR_AT_RESTART
|
if getenv("CLEAR_AT_RESTART", "0") == "1": # Force clear if CLEAR_AT_RESTART
|
||||||
print("Clearing database and file system at restart...")
|
print("Clearing database and file system at restart...")
|
||||||
db.drop_all() # Clear existing tables if configured
|
db.session.remove() # pylint: disable=no-member
|
||||||
db.session.commit() # pylint: disable=no-member
|
db.drop_all()
|
||||||
rmtree(Path("./results"), ignore_errors=True) # Clear results folder
|
rmtree(Path("./results"), ignore_errors=True) # Clear results folder
|
||||||
|
|
||||||
if not db.engine.dialect.has_table(
|
|
||||||
db.engine.connect(), "image"
|
|
||||||
): # If not configured
|
|
||||||
db.create_all()
|
db.create_all()
|
||||||
print("Database structure created successfully.")
|
print("Database structure created successfully.")
|
||||||
|
|
||||||
if getenv("SKIP_IHDR_FILL", "0") == "1":
|
if getenv("SKIP_IHDR_FILL", "0") == "1":
|
||||||
print("Skipping IHDR lookup table fill as per configuration.")
|
print("Skipping IHDR lookup table fill as per configuration.")
|
||||||
else:
|
else:
|
||||||
print("Filling IHDR lookup table...")
|
print("Filling IHDR lookup table...")
|
||||||
create_crc_db()
|
fill_ihdr_db()
|
||||||
print("IHDR table filled successfully.")
|
print("IHDR table filled successfully.")
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- FLASK_DEBUG=true
|
- FLASK_DEBUG=true
|
||||||
- FLASK_ENV=development
|
- FLASK_ENV=development
|
||||||
|
- CLEAR_AT_RESTART=0 # Always false for worker to prevent double clearing
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:8
|
image: redis:8
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ services:
|
|||||||
- postgres
|
- postgres
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
|
environment:
|
||||||
|
- CLEAR_AT_RESTART=0 # Always false for worker to prevent double clearing
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:18
|
image: postgres:18
|
||||||
|
|||||||
Reference in New Issue
Block a user