diff --git a/public/assets/README.md b/public/assets/README.md index 6c5650b..3000e5e 100644 --- a/public/assets/README.md +++ b/public/assets/README.md @@ -1,15 +1,15 @@ # Public assets -Recovered from https://www.anchorhost.eu/ on 2026-06-09. +Existing assets were recovered from https://www.anchorhost.eu/ on 2026-06-09. The hero gallery replacements below are downloaded from Unsplash and used under its free commercial-use license. | File | Size | Source | |------|------|--------| | `transparent_anchorhost.png` | 82 KB | `/assets/transparent_anchorhost.png` | | `hero-bg.jpg` | 41 KB | `/assets/hero-bg.jpg` | -| `pricing-bg.jpg` | Hero gallery: [Ethernet cables connected to a network device](https://unsplash.com/photos/ethernet-cables-connected-to-the-back-of-a-network-device-y4GHs9GEFdM) by Manuel Luikenga (Unsplash License) | +| `data-center.jpg` | Hero gallery: [A rack of servers in a server room](https://unsplash.com/photos/a-rack-of-servers-in-a-server-room-2JJ3wBHu4_0) by Kevin Ache, used under the Unsplash License | +| `fiber-network.jpg` | Hero gallery: [Yellow and green electric wires for optical networks](https://unsplash.com/photos/yellow-and-green-electric-wires-ohBcGYJ8brQ) by Kirill Sh, used under the Unsplash License | | `code.jpg` | 6.6 MB | `/assets/code.jpg` | | `dark-bg.png` | 1.8 MB | `/assets/dark-bg.png` | -| `server-2.jpg` | Hero gallery: [Two server racks filled with electronic components and wires](https://unsplash.com/photos/two-server-racks-filled-with-electronic-components-and-wires-k27hkqXuveo) by Eric Stoynov (Unsplash License) | Root-level icons (in `public/`): diff --git a/public/assets/data-center.jpg b/public/assets/data-center.jpg new file mode 100644 index 0000000..c1f4a8d Binary files /dev/null and b/public/assets/data-center.jpg differ diff --git a/public/assets/fiber-network.jpg b/public/assets/fiber-network.jpg new file mode 100644 index 0000000..d059aa8 Binary files /dev/null and b/public/assets/fiber-network.jpg differ diff --git a/src/features/servers/FileManager.jsx b/src/features/servers/FileManager.jsx index 41c7160..edb1031 100644 --- a/src/features/servers/FileManager.jsx +++ b/src/features/servers/FileManager.jsx @@ -628,12 +628,53 @@ const FileManager = forwardRef(({ serverId, serverImage, sendMessage, isActive, const filePath = getFullPath(file.name); const CHUNK_SIZE = 512 * 1024; // 512KB chunks (reduced to prevent WebSocket frame size issues) const fileSize = file.size; - const totalChunks = Math.ceil(fileSize / CHUNK_SIZE); + const totalChunks = Math.max(1, Math.ceil(fileSize / CHUNK_SIZE)); // Always use chunked upload for better progress tracking and binary file support const chunks = []; let chunkIndex = 0; const reader = new FileReader(); + + const queueUpload = () => { + activeUploadsRef.current[filePath] = { + chunks, + currentChunkIndex: 0, + filePath, + fileName: file.name, + totalSize: fileSize + }; + + setUploadProgress(prev => ({ + ...prev, + [filePath]: { + uploaded: 0, + total: totalChunks, + percentage: 0, + fileName: file.name, + totalSize: fileSize + } + })); + + if (connectionStatus === 'connected') { + sendMessage({ + type: 'start_chunked_upload', + serverId, + filePath, + fileName: file.name, + totalSize: fileSize, + totalChunks, + chunkSize: CHUNK_SIZE + }); + } else { + delete activeUploadsRef.current[filePath]; + setUploadProgress(prev => { + const next = { ...prev }; + delete next[filePath]; + return next; + }); + showAlert('Upload Blocked', 'WebSocket connection not available. Please wait for connection to be restored.', 'warning'); + } + }; reader.onload = (e) => { const chunk = e.target.result; @@ -651,46 +692,7 @@ const FileManager = forwardRef(({ serverId, serverImage, sendMessage, isActive, const end = Math.min(start + CHUNK_SIZE, fileSize); reader.readAsArrayBuffer(file.slice(start, end)); } else { - // All chunks read, start upload - activeUploadsRef.current[filePath] = { - chunks, - currentChunkIndex: 0, - filePath, - fileName: file.name, - totalSize: fileSize - }; - - setUploadProgress(prev => ({ - ...prev, - [filePath]: { - uploaded: 0, - total: totalChunks, - percentage: 0, - fileName: file.name, - totalSize: fileSize - } - })); - - // Initiate chunked upload only if connection is ready - if (connectionStatus === 'connected') { - sendMessage({ - type: 'start_chunked_upload', - serverId: serverId, - filePath: filePath, - fileName: file.name, - totalSize: fileSize, - totalChunks: totalChunks, - chunkSize: CHUNK_SIZE - }); - } else { - console.warn('Cannot start upload - WebSocket not connected. Status:', connectionStatus); - // Remove from active uploads if connection not ready - delete activeUploadsRef.current[filePath]; - const errorProgress = { ...uploadProgress }; - delete errorProgress[filePath]; - setUploadProgress(errorProgress); - showAlert('Upload Blocked', 'WebSocket connection not available. Please wait for connection to be restored.', 'warning'); - } + queueUpload(); } }; @@ -704,8 +706,13 @@ const FileManager = forwardRef(({ serverId, serverImage, sendMessage, isActive, activeUploadsRef.current = errorActiveUploads; }; - // Start reading first chunk - reader.readAsArrayBuffer(file.slice(0, Math.min(CHUNK_SIZE, fileSize))); + // Empty files still use one empty chunk so the upload protocol can create them. + if (fileSize === 0) { + chunks.push(''); + queueUpload(); + } else { + reader.readAsArrayBuffer(file.slice(0, Math.min(CHUNK_SIZE, fileSize))); + } }); // Reset file input @@ -770,6 +777,9 @@ const FileManager = forwardRef(({ serverId, serverImage, sendMessage, isActive,
+ {connectionStatus === 'connected' ? 'Server connected' : 'Reconnect to manage files'} +
{!initialized && (