feat(cli): watch files with event streams
Build and Push Docker Container / build-and-push (push) Successful in 2m3s
Build and Push Docker Container / build-and-push (push) Successful in 2m3s
- Add a private SSE endpoint that emits file change events for authenticated clients. - Replace the watch sleep loop with watchdog local file events and remote SSE triggers. - Debounce local event bursts and keep watch running after transient sync failures. - Add watchdog as a standalone CLI dependency and cover watch behavior in tests. - Bump NanoShare to 1.25.0 and the standalone CLI to 0.4.0.
This commit is contained in:
@@ -45,11 +45,17 @@ def list_remote(client, node: str) -> list[dict]:
|
||||
files = result.get('files', []) if isinstance(result, dict) else []
|
||||
return files if isinstance(files, list) else []
|
||||
|
||||
def download_url(client, node: str, file_id: str) -> str:
|
||||
def node_url(client, node: str, path: str) -> str:
|
||||
base = client.registry.get(node)
|
||||
if not base:
|
||||
raise RuntimeError(f'unknown node: {node}')
|
||||
return f"{base.rstrip('/')}/api/files/{quote(file_id, safe='')}/download"
|
||||
return f"{base.rstrip('/')}{path}"
|
||||
|
||||
def download_url(client, node: str, file_id: str) -> str:
|
||||
return node_url(client, node, f"/api/files/{quote(file_id, safe='')}/download")
|
||||
|
||||
def events_url(client, node: str) -> str:
|
||||
return node_url(client, node, '/api/files/events')
|
||||
|
||||
def download(client, node: str, file_id: str, path: Path) -> None:
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
Reference in New Issue
Block a user