Unified watcher that *may* receive events from inotify and other sources. Added change notify messages from control and upload WebSockets. Cleanup debug printouts.

This commit is contained in:
Leo Vasanko
2026-02-01 02:44:52 +00:00
parent add9d7ac82
commit 80453e98ab
4 changed files with 170 additions and 153 deletions
+6
View File
@@ -1,5 +1,6 @@
import asyncio
import typing
from pathlib import PurePosixPath
from secrets import token_bytes
import msgspec
@@ -53,6 +54,9 @@ async def upload(req, ws):
if pos != req.end:
d = f"{len(data)} bytes" if isinstance(data, bytes) else data
raise ValueError(f"Expected {req.end - pos} more bytes, got {d}")
# Signal the watcher about the uploaded file and its parent directories
path = PurePosixPath(req.name)
watching.notify_change(path, *path.parents)
# Report success
res = StatusMsg(status="ack", req=req)
await asend(ws, res)
@@ -87,6 +91,8 @@ async def control(req, ws):
while True:
cmd = msgspec.json.decode(await ws.recv(), type=ControlTypes)
await asyncio.to_thread(cmd)
# Signal the watcher about affected paths
watching.notify_change(*cmd.affected_paths())
await asend(ws, StatusMsg(status="ack", req=cmd))