Fix control message decoding.

This commit is contained in:
Leo Vasanko 2023-11-01 14:12:06 +00:00
parent 9002afbc7e
commit a26dc42d88
2 changed files with 5 additions and 2 deletions

View File

@ -6,7 +6,7 @@ from sanic import Blueprint
from cista import watching
from cista.fileio import FileServer
from cista.protocol import ControlBase, FileRange, StatusMsg
from cista.protocol import ControlTypes, FileRange, StatusMsg
from cista.util.apphelpers import asend, websocket_wrapper
bp = Blueprint("api", url_prefix="/api")
@ -76,7 +76,7 @@ async def download(req, ws):
@bp.websocket("control")
@websocket_wrapper
async def control(req, ws):
cmd = msgspec.json.decode(await ws.recv(), type=ControlBase)
cmd = msgspec.json.decode(await ws.recv(), type=ControlTypes)
await asyncio.to_thread(cmd)
await asend(ws, StatusMsg(status="ack", req=cmd))

View File

@ -78,6 +78,9 @@ class Cp(ControlBase):
)
ControlTypes = MkDir | Rename | Rm | Mv | Cp
## File uploads and downloads