🐛(frontend) Cancel active uploads when parent folder is deleted#656
🐛(frontend) Cancel active uploads when parent folder is deleted#656PanchoutNathan wants to merge 4 commits intomainfrom
Conversation
Track each uploading file's drop target folder via a Map. When a folder is deleted, selectively cancel only the uploads that were dropped into that folder, leaving other uploads unaffected.
Test two scenarios: deleting the current folder cancels its uploads, and deleting one folder does not cancel uploads targeting a different folder.
32cbe5c to
ef817dd
Compare
There was a problem hiding this comment.
Does not work if you delete a parent of the target folder.
- Create folder A
- Create folder B
- Go to folder B
- Drop files inside folder B
- Go up in folder A
- Delete folder A
- BUG: the uploading items are not stopped
| (deletedIds: string[]) => { | ||
| if (!isProcessingRef.current) return; | ||
| const deletedSet = new Set(deletedIds); | ||
| for (const [filePath, dropTargetId] of fileDropTargetRef.current) { |
There was a problem hiding this comment.
optimization: you are iterating over this entire set instead of using the map capabilities to retrieve the target id.
Instead, loop of deleteIds and fileDropTargetRef.curent.get(deletedId). Greatly reduce the O().
There was a problem hiding this comment.
I wonder: why is this required? Cancelling an item should just remove it from uploadQueueRef nope?
This way, is cancelledRef still required?
| // Whether the upload processing loop is currently running | ||
| const isProcessingRef = useRef(false); | ||
| // Map of filePath → drop target folder ID (for selective cancellation on deletion) | ||
| const fileDropTargetRef = useRef<Map<string, string>>(new Map()); |
There was a problem hiding this comment.
Why is this new ref needed as the target parentId is already stored in uploadQueueRef?
There was a problem hiding this comment.
It duplicates in multiple places the same data, leading to harder maintenability + risk of desync.
|



Summary
via a Map (
fileDropTargetRef)the uploads that were dropped into that folder,
leaving other concurrent uploads unaffected
useDeleteItemandExplorerSelectionBardeletion paths