Skip to content

Commit e9f6a4a

Browse files
committed
add name to chunk request
1 parent 234fef5 commit e9f6a4a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/textual_serve/app_service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ async def on_meta(self, data: bytes) -> None:
319319
open_method=meta_data["open_method"],
320320
mime_type=meta_data["mime_type"],
321321
encoding=meta_data["encoding"],
322+
name=meta_data.get("name", None),
322323
)
323324
except KeyError:
324325
log.error("Missing key in `deliver_file_start` meta packet")

src/textual_serve/download_manager.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ class Download:
3737
Will be None if the content is binary.
3838
"""
3939

40+
name: str | None = None
41+
"""Optional name set bt the client."""
42+
4043
incoming_chunks: asyncio.Queue[bytes | None] = field(default_factory=asyncio.Queue)
4144
"""A queue of incoming chunks for the download.
4245
Chunks are sent from the app service to the download handler
@@ -52,7 +55,7 @@ class DownloadManager:
5255
running app processes.
5356
"""
5457

55-
def __init__(self):
58+
def __init__(self) -> None:
5659
self._active_downloads: dict[str, Download] = {}
5760
"""A dictionary of active downloads.
5861
@@ -73,6 +76,7 @@ async def create_download(
7376
open_method: str,
7477
mime_type: str,
7578
encoding: str | None = None,
79+
name: str | None = None,
7680
) -> None:
7781
"""Prepare for a new download.
7882
@@ -91,6 +95,7 @@ async def create_download(
9195
open_method,
9296
mime_type,
9397
encoding,
98+
name=name,
9499
)
95100

96101
async def download(self, delivery_key: str) -> AsyncGenerator[bytes, None]:
@@ -111,6 +116,7 @@ async def download(self, delivery_key: str) -> AsyncGenerator[bytes, None]:
111116
"type": "deliver_chunk_request",
112117
"key": delivery_key,
113118
"size": DOWNLOAD_CHUNK_SIZE,
119+
"name": download.name,
114120
}
115121
)
116122

0 commit comments

Comments
 (0)