Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a03397-4d51-7fd1-8ff2-946eb22ea2bc
This commit is contained in:
parent
408d32df88
commit
74b2f27997
20 changed files with 608 additions and 182 deletions
|
|
@ -7,7 +7,7 @@ from pathlib import Path
|
|||
from typing import Iterable
|
||||
from uuid import uuid4
|
||||
|
||||
SCHEMA_VERSION = 1
|
||||
SCHEMA_VERSION = 2
|
||||
|
||||
|
||||
class Store:
|
||||
|
|
@ -38,6 +38,7 @@ class Store:
|
|||
pid INTEGER NOT NULL,
|
||||
session TEXT NOT NULL,
|
||||
repos TEXT NOT NULL,
|
||||
delivery_mode TEXT NOT NULL DEFAULT 'manual',
|
||||
connected_at REAL NOT NULL,
|
||||
disconnected_at REAL
|
||||
);
|
||||
|
|
@ -49,23 +50,43 @@ class Store:
|
|||
expires_at REAL NOT NULL
|
||||
);
|
||||
""")
|
||||
self.db.execute("INSERT OR IGNORE INTO metadata(key,value) VALUES('schema_version',?)", (str(SCHEMA_VERSION),))
|
||||
endpoint_columns = {
|
||||
row["name"] for row in self.db.execute("PRAGMA table_info(endpoints)")
|
||||
}
|
||||
if "delivery_mode" not in endpoint_columns:
|
||||
self.db.execute(
|
||||
"ALTER TABLE endpoints ADD COLUMN delivery_mode TEXT NOT NULL DEFAULT 'manual'"
|
||||
)
|
||||
self.db.execute(
|
||||
"INSERT INTO metadata(key,value) VALUES('schema_version',?) "
|
||||
"ON CONFLICT(key) DO UPDATE SET value=excluded.value",
|
||||
(str(SCHEMA_VERSION),),
|
||||
)
|
||||
self.db.commit()
|
||||
|
||||
def close(self) -> None:
|
||||
self.db.close()
|
||||
|
||||
def register_endpoint(self, endpoint_id: str, pid: int, session: str, repos: list[str]) -> None:
|
||||
def register_endpoint(
|
||||
self,
|
||||
endpoint_id: str,
|
||||
pid: int,
|
||||
session: str,
|
||||
repos: list[str],
|
||||
delivery_mode: str = "manual",
|
||||
) -> None:
|
||||
import json
|
||||
if delivery_mode not in {"manual", "pane"}:
|
||||
raise ValueError(f"invalid delivery mode: {delivery_mode}")
|
||||
self.db.execute(
|
||||
"UPDATE endpoints SET disconnected_at=strftime('%s','now') "
|
||||
"WHERE pid=? AND session=? AND endpoint_id<>? AND disconnected_at IS NULL",
|
||||
(pid, session, endpoint_id),
|
||||
)
|
||||
self.db.execute(
|
||||
"INSERT INTO endpoints(endpoint_id,pid,session,repos,connected_at,disconnected_at) VALUES(?,?,?,?,strftime('%s','now'),NULL) "
|
||||
"ON CONFLICT(endpoint_id) DO UPDATE SET pid=excluded.pid, session=excluded.session, repos=excluded.repos, connected_at=excluded.connected_at, disconnected_at=NULL",
|
||||
(endpoint_id, pid, session, json.dumps(repos)),
|
||||
"INSERT INTO endpoints(endpoint_id,pid,session,repos,delivery_mode,connected_at,disconnected_at) VALUES(?,?,?,?,?,strftime('%s','now'),NULL) "
|
||||
"ON CONFLICT(endpoint_id) DO UPDATE SET pid=excluded.pid, session=excluded.session, repos=excluded.repos, delivery_mode=excluded.delivery_mode, connected_at=excluded.connected_at, disconnected_at=NULL",
|
||||
(endpoint_id, pid, session, json.dumps(repos), delivery_mode),
|
||||
)
|
||||
self.db.commit()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue