From 7e1290c5d92fb33af2dc34bd53cdab5371d988c4 Mon Sep 17 00:00:00 2001 From: Zeecka Date: Wed, 31 Dec 2025 16:30:12 +0100 Subject: [PATCH] work still in progress --- aperisolve/models.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/aperisolve/models.py b/aperisolve/models.py index 6b300f8..9d82e8c 100644 --- a/aperisolve/models.py +++ b/aperisolve/models.py @@ -130,12 +130,13 @@ def init_db(app: Flask) -> None: - Prints status messages to console during initialization """ with app.app_context(): - if not db.engine.dialect.has_table(db.engine.connect(), "image"): - 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 + 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 + 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":