fix(file-manager): send queued chunks after upload start
Build and publish Docker image / build-and-publish (push) Successful in 13s
Build and publish Docker image / build-and-publish (push) Successful in 13s
This commit is contained in:
1 parent
8e3a6d3446
commit
fbcd814ef7
2 files changed
+8
-11
No files matched your search
@@ -287,8 +287,8 @@ const FileManager = forwardRef(({ serverId, serverImage, sendMessage, isActive,
|
|||||||
const uploadInfo = activeUploadsRef.current[chunkFilePath];
|
const uploadInfo = activeUploadsRef.current[chunkFilePath];
|
||||||
const { chunks, currentChunkIndex } = uploadInfo;
|
const { chunks, currentChunkIndex } = uploadInfo;
|
||||||
|
|
||||||
// Only send next chunk if connection is ready
|
// sendMessage queues the chunk if the socket is reconnecting.
|
||||||
if (currentChunkIndex < chunks.length && connectionStatus === 'connected') {
|
if (currentChunkIndex < chunks.length) {
|
||||||
sendMessage({
|
sendMessage({
|
||||||
type: 'upload_file_chunk',
|
type: 'upload_file_chunk',
|
||||||
serverId: serverId,
|
serverId: serverId,
|
||||||
@@ -308,9 +308,6 @@ const FileManager = forwardRef(({ serverId, serverImage, sendMessage, isActive,
|
|||||||
totalSize: uploadInfo.totalSize
|
totalSize: uploadInfo.totalSize
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
} else if (connectionStatus !== 'connected') {
|
|
||||||
// Connection not ready, chunk will be sent when connection is restored
|
|
||||||
console.log('Upload paused - WebSocket not connected. Status:', connectionStatus);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -328,8 +325,8 @@ const FileManager = forwardRef(({ serverId, serverImage, sendMessage, isActive,
|
|||||||
resumeAttemptedRef.current.delete(startedFilePath);
|
resumeAttemptedRef.current.delete(startedFilePath);
|
||||||
// Reset chunk index to start from beginning (in case of resume)
|
// Reset chunk index to start from beginning (in case of resume)
|
||||||
uploadInfo.currentChunkIndex = 0;
|
uploadInfo.currentChunkIndex = 0;
|
||||||
// Only send first chunk if connection is ready
|
// sendMessage queues the chunk if the socket is reconnecting.
|
||||||
if (chunks.length > 0 && connectionStatus === 'connected') {
|
if (chunks.length > 0) {
|
||||||
sendMessage({
|
sendMessage({
|
||||||
type: 'upload_file_chunk',
|
type: 'upload_file_chunk',
|
||||||
serverId: serverId,
|
serverId: serverId,
|
||||||
@@ -349,8 +346,6 @@ const FileManager = forwardRef(({ serverId, serverImage, sendMessage, isActive,
|
|||||||
totalSize: uploadInfo.totalSize
|
totalSize: uploadInfo.totalSize
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
} else if (connectionStatus !== 'connected') {
|
|
||||||
console.log('Upload started but connection not ready. Will resume when connected. Status:', connectionStatus);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -871,9 +871,11 @@ const handleWebSocketMessage = useCallback((data) => {
|
|||||||
|
|
||||||
// First, let the file manager handle file-related messages
|
// First, let the file manager handle file-related messages
|
||||||
// For upload_error, also forward if it's a file-related message (even if serverId doesn't match exactly)
|
// For upload_error, also forward if it's a file-related message (even if serverId doesn't match exactly)
|
||||||
|
const isUploadMessage = [
|
||||||
|
'upload_started', 'upload_chunk_received', 'upload_error', 'file_uploaded'
|
||||||
|
].includes(data.type);
|
||||||
const shouldForwardToFileManager = fileManagerRef.current && (
|
const shouldForwardToFileManager = fileManagerRef.current && (
|
||||||
String(data.serverId) === String(selectedServer?.id) ||
|
String(data.serverId) === String(selectedServer?.id) || isUploadMessage
|
||||||
(data.type === 'upload_error' && data.filePath) // Forward upload_error even if serverId mismatch
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (shouldForwardToFileManager) {
|
if (shouldForwardToFileManager) {
|
||||||
|
|||||||
Reference in new issue
Block a user