Now working
This commit is contained in:
+2
-1
@@ -33,9 +33,10 @@ app.config["MAX_CONTENT_LENGTH"] = int(
|
||||
)
|
||||
RESULT_FOLDER.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
db.init_app(app)
|
||||
with app.app_context():
|
||||
init_db(app)
|
||||
|
||||
redis_conn = Redis(host="redis", port=6379)
|
||||
queue = Queue(connection=redis_conn)
|
||||
|
||||
|
||||
@@ -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.")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user