Skip to content

🐛(frontend) Cancel active uploads when parent folder is deleted#656

Open
PanchoutNathan wants to merge 4 commits intomainfrom
fix/stop-upload-when-deleting-parent-folder
Open

🐛(frontend) Cancel active uploads when parent folder is deleted#656
PanchoutNathan wants to merge 4 commits intomainfrom
fix/stop-upload-when-deleting-parent-folder

Conversation

@PanchoutNathan
Copy link
Copy Markdown
Contributor

Summary

  • Track each uploading file's drop target folder
    via a Map (fileDropTargetRef)
  • When a folder is deleted, selectively cancel only
    the uploads that were dropped into that folder,
    leaving other concurrent uploads unaffected
  • Hook into both useDeleteItem and
    ExplorerSelectionBar deletion paths

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.
@PanchoutNathan PanchoutNathan linked an issue Apr 10, 2026 that may be closed by this pull request
@PanchoutNathan PanchoutNathan changed the title Cancel active uploads when parent folder is deleted ✨(frontend) Cancel active uploads when parent folder is deleted Apr 10, 2026
@PanchoutNathan PanchoutNathan changed the title ✨(frontend) Cancel active uploads when parent folder is deleted 🐛(frontend) Cancel active uploads when parent folder is deleted Apr 10, 2026
Test two scenarios: deleting the current folder cancels
its uploads, and deleting one folder does not cancel
uploads targeting a different folder.
@PanchoutNathan PanchoutNathan force-pushed the fix/stop-upload-when-deleting-parent-folder branch from 32cbe5c to ef817dd Compare April 10, 2026 10:24
@PanchoutNathan PanchoutNathan self-assigned this Apr 10, 2026
@PanchoutNathan PanchoutNathan mentioned this pull request Apr 10, 2026
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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().

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this new ref needed as the target parentId is already stored in uploadQueueRef?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It duplicates in multiple places the same data, leading to harder maintenability + risk of desync.

@sonarqubecloud
Copy link
Copy Markdown

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.

Stop uploading when the parent folder is deleted

2 participants