FlowNotFound says whether a published flow or any flow is missing; read_all stamps its cache with the revision from before its scan; dashboard discard and delete commits name the key; a RedisState ttl expires counters and the names set too; bench_startup publishes the version after its saves, and only when there is a draft

This commit is contained in:
2026-11-04 21:20:29 +01:00
parent b7f1d21712
commit eb17528ce6
5 changed files with 70 additions and 16 deletions
+9 -5
View File
@@ -202,12 +202,14 @@ def new_id(kind: Literal["f", "d"], taken: Callable[[str], bool]) -> str:
class FlowNotFound(KeyError):
def __init__(self, name: str) -> None:
def __init__(self, name: str, published: bool = False) -> None:
super().__init__(name)
self.name = name
self.published = published
def __str__(self) -> str:
return f"No flow named '{self.name}'"
what = "published flow" if self.published else "flow"
return f"No {what} with the id '{self.name}'"
class FlowExists(ValueError):
@@ -720,7 +722,7 @@ class FlowStore:
return self._load(path)
path = self._flow_file(name)
if not path.exists():
raise FlowNotFound(name)
raise FlowNotFound(name, published=not draft)
return self._load(path)
def key_index(self) -> dict[str, str]:
@@ -782,7 +784,9 @@ class FlowStore:
and returned as a copy so a caller sorting it cannot disturb the next.
"""
with self._read_all_lock:
if self._read_all_at != self.revision:
# Taken before scanning, so a commit landing meanwhile scans again.
at = self.revision
if self._read_all_at != at:
flows = []
for path in sorted(self.root.glob("*/flow.json")):
name = path.parent.name
@@ -791,7 +795,7 @@ class FlowStore:
except Exception:
logger.exception("Skipping unreadable flow '%s'", name)
self._read_all = flows
self._read_all_at = self.revision
self._read_all_at = at
return list(self._read_all)
def write_flow(self, flow: FlowDef) -> bool: