Now working

This commit is contained in:
Zeecka
2025-12-31 22:47:20 +01:00
parent ad9501a3b2
commit 60bed74a0d
4 changed files with 18 additions and 16 deletions
+3 -2
View File
@@ -33,9 +33,10 @@ app.config["MAX_CONTENT_LENGTH"] = int(
)
RESULT_FOLDER.mkdir(parents=True, exist_ok=True)
db.init_app(app)
init_db(app)
with app.app_context():
init_db(app)
redis_conn = Redis(host="redis", port=6379)
queue = Queue(connection=redis_conn)
+5 -7
View File
@@ -62,7 +62,7 @@ class IHDR(db.Model): # type: ignore
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
combinations of standard PNG parameters such as resolutions, bit depths,
@@ -132,18 +132,16 @@ def init_db(app: Flask) -> None:
with app.app_context():
if getenv("CLEAR_AT_RESTART", "0") == "1": # Force clear if CLEAR_AT_RESTART
print("Clearing database and file system at restart...")
db.drop_all() # Clear existing tables if configured
db.session.commit() # pylint: disable=no-member
db.session.remove() # pylint: disable=no-member
db.drop_all()
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()
print("Database structure created successfully.")
if getenv("SKIP_IHDR_FILL", "0") == "1":
print("Skipping IHDR lookup table fill as per configuration.")
else:
print("Filling IHDR lookup table...")
create_crc_db()
fill_ihdr_db()
print("IHDR table filled successfully.")
+1
View File
@@ -41,6 +41,7 @@ services:
environment:
- FLASK_DEBUG=true
- FLASK_ENV=development
- CLEAR_AT_RESTART=0 # Always false for worker to prevent double clearing
redis:
image: redis:8
+2
View File
@@ -37,6 +37,8 @@ services:
- postgres
env_file:
- .env
environment:
- CLEAR_AT_RESTART=0 # Always false for worker to prevent double clearing
postgres:
image: postgres:18