mirror of
https://github.com/Textualize/textual-serve.git
synced 2025-10-17 02:50:37 +03:00
add name to chunk request
This commit is contained in:
@@ -319,6 +319,7 @@ class AppService:
|
|||||||
open_method=meta_data["open_method"],
|
open_method=meta_data["open_method"],
|
||||||
mime_type=meta_data["mime_type"],
|
mime_type=meta_data["mime_type"],
|
||||||
encoding=meta_data["encoding"],
|
encoding=meta_data["encoding"],
|
||||||
|
name=meta_data.get("name", None),
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
log.error("Missing key in `deliver_file_start` meta packet")
|
log.error("Missing key in `deliver_file_start` meta packet")
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ class Download:
|
|||||||
Will be None if the content is binary.
|
Will be None if the content is binary.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
name: str | None = None
|
||||||
|
"""Optional name set bt the client."""
|
||||||
|
|
||||||
incoming_chunks: asyncio.Queue[bytes | None] = field(default_factory=asyncio.Queue)
|
incoming_chunks: asyncio.Queue[bytes | None] = field(default_factory=asyncio.Queue)
|
||||||
"""A queue of incoming chunks for the download.
|
"""A queue of incoming chunks for the download.
|
||||||
Chunks are sent from the app service to the download handler
|
Chunks are sent from the app service to the download handler
|
||||||
@@ -52,7 +55,7 @@ class DownloadManager:
|
|||||||
running app processes.
|
running app processes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self) -> None:
|
||||||
self._active_downloads: dict[str, Download] = {}
|
self._active_downloads: dict[str, Download] = {}
|
||||||
"""A dictionary of active downloads.
|
"""A dictionary of active downloads.
|
||||||
|
|
||||||
@@ -73,6 +76,7 @@ class DownloadManager:
|
|||||||
open_method: str,
|
open_method: str,
|
||||||
mime_type: str,
|
mime_type: str,
|
||||||
encoding: str | None = None,
|
encoding: str | None = None,
|
||||||
|
name: str | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Prepare for a new download.
|
"""Prepare for a new download.
|
||||||
|
|
||||||
@@ -91,6 +95,7 @@ class DownloadManager:
|
|||||||
open_method,
|
open_method,
|
||||||
mime_type,
|
mime_type,
|
||||||
encoding,
|
encoding,
|
||||||
|
name=name,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def download(self, delivery_key: str) -> AsyncGenerator[bytes, None]:
|
async def download(self, delivery_key: str) -> AsyncGenerator[bytes, None]:
|
||||||
@@ -111,6 +116,7 @@ class DownloadManager:
|
|||||||
"type": "deliver_chunk_request",
|
"type": "deliver_chunk_request",
|
||||||
"key": delivery_key,
|
"key": delivery_key,
|
||||||
"size": DOWNLOAD_CHUNK_SIZE,
|
"size": DOWNLOAD_CHUNK_SIZE,
|
||||||
|
"name": download.name,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user