feat(server): modularize backend and admin console
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import sqlite3
|
||||
|
||||
|
||||
def version_exists(conn: sqlite3.Connection, app_id: str, channel: str, version: str) -> bool:
|
||||
return conn.execute(
|
||||
"SELECT 1 FROM versions WHERE app_id=? AND channel=? AND version=?",
|
||||
(app_id, channel, version),
|
||||
).fetchone() is not None
|
||||
|
||||
|
||||
def create_version(conn: sqlite3.Connection, app_id: str, channel: str, version: str, client_protocol: int) -> int:
|
||||
conn.execute("UPDATE versions SET latest=0 WHERE app_id=? AND channel=?", (app_id, channel))
|
||||
cur = conn.execute(
|
||||
"INSERT INTO versions(app_id, channel, version, latest, client_protocol) VALUES (?,?,?,1,?)",
|
||||
(app_id, channel, version, client_protocol),
|
||||
)
|
||||
return int(cur.lastrowid)
|
||||
|
||||
|
||||
def insert_version_file(conn: sqlite3.Connection, version_id: int, path: str, sha256: str, size: int):
|
||||
conn.execute(
|
||||
"INSERT INTO version_files(version_id, path, sha256, size) VALUES (?,?,?,?)",
|
||||
(version_id, path, sha256, size),
|
||||
)
|
||||
Reference in New Issue
Block a user