Integrate Obfuscator file picker into Contracts
Deploy contracts-flask / validate (push) Canceled after 0s
Deploy contracts-flask / validate (push) Canceled after 0s
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
+16
-12
@@ -34,17 +34,9 @@ def transaction():
|
||||
|
||||
|
||||
def init_db():
|
||||
"""Создать/пересоздать БД + схему. Вызывается при старте и после cleanup."""
|
||||
"""Create the database schema without deleting persisted data."""
|
||||
global _db_session_key
|
||||
_db_session_key = time.time()
|
||||
|
||||
# Удалить старый файл + WAL-сателлиты
|
||||
for f in (DB_PATH, DB_PATH + "-wal", DB_PATH + "-shm"):
|
||||
try:
|
||||
os.remove(f)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
_db_session_key = time.time_ns()
|
||||
conn = get_conn()
|
||||
_create_schema(conn)
|
||||
return conn
|
||||
@@ -147,8 +139,20 @@ def _create_schema(conn):
|
||||
|
||||
|
||||
def cleanup_db():
|
||||
"""Удалить БД полностью. Вызывает init_db() для создания новой."""
|
||||
init_db()
|
||||
"""Explicitly delete the database and recreate an empty schema."""
|
||||
global _db_session_key
|
||||
conn = getattr(_local, "conn", None)
|
||||
if conn is not None:
|
||||
conn.close()
|
||||
_local.conn = None
|
||||
_local.session_key = None
|
||||
_db_session_key = time.time_ns()
|
||||
for path in (DB_PATH, DB_PATH + "-wal", DB_PATH + "-shm"):
|
||||
try:
|
||||
os.remove(path)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
return init_db()
|
||||
|
||||
|
||||
def get_conn():
|
||||
|
||||
Reference in New Issue
Block a user