Skip to content

Conversation

jenken827
Copy link
Contributor

@xrgzs xrgzs changed the title feat(fs):slice upload feat(fs): slice upload Aug 24, 2025
@xrgzs xrgzs requested a review from Copilot August 24, 2025 18:39
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 105 to 106
onUploadProgress: async (progressEvent) => {
log()
Copy link
Preview

Copilot AI Aug 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
onUploadProgress: async (progressEvent) => {
log()

Copilot uses AI. Check for mistakes.

Comment on lines 116 to 118
oldLoaded = progressEvent.loaded
} finally {
progressMutex.release()
Copy link
Preview

Copilot AI Aug 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mutex is being released incorrectly. The 'release' variable from 'progressMutex.acquire()' should be called, not 'progressMutex.release()'. Change line 118 to 'release()' instead.

Suggested change
oldLoaded = progressEvent.loaded
} finally {
progressMutex.release()
release()

Copilot uses AI. Check for mistakes.

Comment on lines 140 to 141
const speed = intervalLoaded / ((Date.now() - lastTimestamp) / 1000)
const complete = Math.min(100, ((uploadedBytes / file.size) * 100) | 0)
Copy link
Preview

Copilot AI Aug 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bitwise OR operation '| 0' for rounding is unclear. Use 'Math.floor()' instead for better readability and explicit intent.

Suggested change
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))

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@jenken827
Copy link
Contributor Author

优化了上传状态展示

@j2rong4cn j2rong4cn marked this pull request as draft August 28, 2025 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants