You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(FR-1501): fix file upload status tracking and error handling (#4412)
Resolves#4316 ([FR-1501](https://lablup.atlassian.net/browse/FR-1501))
## Changes
Fixes file upload status tracking and progress calculation issues, particularly for concurrent uploads. Refactored the upload state management to properly track upload progress using bytes instead of just file counts.
### Key Changes
1. Enhanced State Management Structure
2. Fixed Progress Calculation
- Problem: Progress was only tracked by file count, not actual bytes uploaded
- Solution:
- Added completedBytes to track actual upload progress
- Added totalExpectedSize for accurate percentage calculation
- Progress now shows: completedBytes / totalExpectedSize * 100
3. Fixed Cumulative Bytes Issue
- Problem: onProgress callback provides cumulative bytesUploaded, not incremental
- Solution: Calculate delta bytes for each progress update
```
let previousBytesUploaded = 0;
const deltaBytes = bytesUploaded - previousBytesUploaded;
previousBytesUploaded = bytesUploaded;
```
4. Improved Concurrent Upload Handling
- Problem: When starting new uploads while others are in progress, total size wasn't properly accumulated
- Solution:
- totalExpectedSize accumulates across all upload requests
- All progress callbacks reference the same total from state
- Proper reset when all uploads complete
5. Better Upload Status Notifications
- Progress notifications now show both file count and byte-based percentage
- More accurate progress tracking during uploads
- Proper cleanup of state after completion
Testing
- Single file upload progress tracking
- Multiple files upload (folder) progress tracking
- Concurrent uploads (starting new upload while another
is in progress)
- Upload failure handling
- Progress percentage accuracy
Technical Details
The main issue was that the original implementation only tracked file names without considering actual bytes uploaded. This led to inaccurate progress reporting, especially for files of varying sizes. The new implementation:
1. Tracks both file counts and bytes for comprehensive progress reporting
2. Properly handles cumulative vs incremental byte reporting from the TUS upload library
3. Maintains a single source of truth (totalExpectedSize) for all concurrent uploads
4. Correctly accumulates sizes when new uploads are added
**Checklist:**
- [ ] Documentation
- [ ] Minimum required manager version
- [ ] Specific setting for review
- [ ] Minimum requirements to check during review
- [x] Test case: Upload multiple files and verify status tracking works correctly
[FR-1501]: https://lablup.atlassian.net/browse/FR-1501?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
0 commit comments