fix(file-manager): preserve upload path correlation
Build and publish Docker image / build-and-publish (push) Successful in 11s

This commit is contained in:
wfalkowski committed 2026-10-23 21:17:55 +00:00
1 parent 2fcd0c3ef9
commit 59afb2ed03
2 files changed
+21 -3

No files matched your search

+19 -3
View File
@@ -13,10 +13,12 @@ class ChunkedUploadTests(unittest.TestCase):
content: bytes,
write_success: bool = True,
chunk_data: str | None = None,
normalize_path: bool = False,
) -> tuple[list[dict], bytes]:
client_id = "upload-test-client"
server_id = "upload-test-server"
file_path = "/data/upload-check.bin"
file_path = "/upload-check.bin" if normalize_path else "/data/upload-check.bin"
server_file_path = f"/data{file_path}" if normalize_path else file_path
captured_content = b""
messages: list[dict] = []
@@ -42,7 +44,13 @@ class ChunkedUploadTests(unittest.TestCase):
try:
with (
patch.object(websocket_service, "send_message", new=AsyncMock(side_effect=capture_message)),
patch.object(websocket_service, "validate_path_for_server", side_effect=lambda _server, path: path),
patch.object(
websocket_service,
"validate_path_for_server",
side_effect=lambda _server, path: (
path if path.startswith("/data") else f"/data{path}"
) if normalize_path else path,
),
patch.object(
websocket_service,
"get_server_access_and_namespace",
@@ -71,7 +79,7 @@ class ChunkedUploadTests(unittest.TestCase):
client_id,
{
"serverId": server_id,
"filePath": file_path,
"filePath": server_file_path,
"chunkIndex": 0,
"chunkData": chunk_data if chunk_data is not None else base64.b64encode(content).decode("ascii"),
"totalChunks": 1,
@@ -102,6 +110,14 @@ class ChunkedUploadTests(unittest.TestCase):
self.assertEqual(uploaded, b"")
self.assertEqual(messages[-1]["type"], "file_uploaded")
def test_upload_ack_preserves_client_path_when_server_normalizes_path(self) -> None:
messages, uploaded = self._upload(b"payload", normalize_path=True)
self.assertEqual(uploaded, b"payload")
self.assertEqual(messages[0]["type"], "upload_started")
self.assertEqual(messages[0]["filePath"], "/data/upload-check.bin")
self.assertEqual(messages[0]["clientFilePath"], "/upload-check.bin")
def test_upload_reports_storage_failure(self) -> None:
messages, _uploaded = self._upload(b"payload", write_success=False)
+2
View File
@@ -2111,6 +2111,7 @@ async def handle_start_chunked_upload(client_id, data):
return
try:
client_file_path = file_path
# Validate path for Minecraft servers
file_path = validate_path_for_server(server_id, file_path)
@@ -2150,6 +2151,7 @@ async def handle_start_chunked_upload(client_id, data):
'type': 'upload_started',
'serverId': server_id,
'filePath': file_path,
'clientFilePath': client_file_path,
'uploadId': upload_id
})
except Exception as e: