Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements slice upload functionality for the file upload system. The slice upload feature allows large files to be uploaded in multiple chunks/slices for better reliability and potentially resumable uploads.
Key changes include:
- Addition of slice upload core logic with concurrent chunk uploading
- New API interfaces for slice upload operations (preup, upload info, complete)
- Integration of slice upload option into existing upload flows
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| vite.config.ts | Externalized p-limit dependency for chunk management |
| src/types/resp.ts | Added response types for slice upload API endpoints |
| src/pages/home/uploads/util.ts | Enhanced hash calculation and added slice upload utility functions |
| src/pages/home/uploads/types.ts | Added HashInfo type and slice upload parameter to Upload type |
| src/pages/home/uploads/stream.ts | Integrated slice upload option into stream upload flow |
| src/pages/home/uploads/slice_upload.ts | Core slice upload implementation with concurrent uploading |
| src/pages/home/uploads/form.ts | Added slice upload option to form upload flow |
| src/pages/home/uploads/Upload.tsx | Added slice upload checkbox to UI |
| src/lang/en/home.json | Added localization for slice upload option |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| onUploadProgress: async (progressEvent) => { | ||
| log() |
There was a problem hiding this comment.
The log() function is called without any arguments on line 106, which may not provide useful debugging information. Consider adding meaningful parameters or removing if not needed.
| onUploadProgress: async (progressEvent) => { | |
| log() |
| oldLoaded = progressEvent.loaded | ||
| } finally { | ||
| progressMutex.release() |
There was a problem hiding this comment.
The mutex is being released incorrectly. The 'release' variable from 'progressMutex.acquire()' should be called, not 'progressMutex.release()'. Change line 118 to 'release()' instead.
| oldLoaded = progressEvent.loaded | |
| } finally { | |
| progressMutex.release() | |
| release() |
| const speed = intervalLoaded / ((Date.now() - lastTimestamp) / 1000) | ||
| const complete = Math.min(100, ((uploadedBytes / file.size) * 100) | 0) |
There was a problem hiding this comment.
The bitwise OR operation '| 0' for rounding is unclear. Use 'Math.floor()' instead for better readability and explicit intent.
| const speed = intervalLoaded / ((Date.now() - lastTimestamp) / 1000) | |
| const complete = Math.min(100, ((uploadedBytes / file.size) * 100) | 0) | |
| const complete = Math.min(100, Math.floor((uploadedBytes / file.size) * 100)) |
|
优化了上传状态展示 |
…ce upload functions
…ent, and memory optimization
…th check, error handling, and retry mechanisms
…rocessing logic after server restart, and adjusted the retry configuration
…frontend into pr/jenken827/187
参见:feat:支持分片上传