Skip to content

Commit adb2bd4

Browse files
committed
Deleted WS download endpoint
1 parent 3a3b207 commit adb2bd4

File tree

1 file changed

+0
-52
lines changed

1 file changed

+0
-52
lines changed

views/websockets.py

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -74,55 +74,3 @@ async def websocket_upload(websocket: WebSocket, uid: str):
7474
)
7575

7676
transfer.info("△ Upload complete.")
77-
78-
79-
@warnings.deprecated(
80-
"This endpoint is deprecated and will be removed soon. "
81-
"It should not be used for reference, and it is disabled on the website."
82-
)
83-
@router.websocket("/receive/{uid}")
84-
async def websocket_download(background_tasks: BackgroundTasks, websocket: WebSocket, uid: str):
85-
await websocket.accept()
86-
log.debug("▼ Websocket download request.")
87-
88-
try:
89-
transfer = await FileTransfer.get(uid)
90-
except KeyError:
91-
log.warning("▼ File not found.")
92-
await websocket.send_text("File not found")
93-
return
94-
95-
if await transfer.is_receiver_connected():
96-
log.warning("▼ A client is already downloading this file.")
97-
await websocket.send_text("Error: A client is already downloading this file.")
98-
return
99-
100-
file_name, file_size, file_type = transfer.get_file_info()
101-
transfer.debug(f"▼ File: name={file_name}, size={file_size}, type={file_type}")
102-
await websocket.send_json({'file_name': file_name, 'file_size': file_size, 'file_type': file_type})
103-
104-
transfer.info("▼ Waiting for go-ahead...")
105-
while True:
106-
try:
107-
msg = await websocket.receive_text()
108-
if msg == "Go for file chunks":
109-
break
110-
transfer.warning(f"▼ Unexpected message: {msg}")
111-
except WebSocketDisconnect:
112-
transfer.warning("▼ Client disconnected while waiting for go-ahead")
113-
return
114-
115-
if not await transfer.set_receiver_connected():
116-
log.warning("▼ A client is already downloading this file.")
117-
await websocket.send_text("Error: A client is already downloading this file.")
118-
return
119-
120-
transfer.info("▼ Notifying client is connected.")
121-
await transfer.set_client_connected()
122-
background_tasks.add_task(transfer.finalize_download)
123-
124-
transfer.info("▼ Starting download...")
125-
async for chunk in transfer.supply_download(on_error=send_error_and_close(websocket)):
126-
await websocket.send_bytes(chunk)
127-
await websocket.send_bytes(b'')
128-
transfer.info("▼ Download complete.")

0 commit comments

Comments
 (0)