Commit 4af22ab
committed
Bugfix: Don't double-dispatch MCP autoConfirm copies
`waitForScanThenStart` in `TransferProgressDialog.svelte` had a race: it subscribed to `scan-preview-complete` first, then awaited `checkScanPreviewStatus`. If the scan completed during that await (common for small sources over MCP, where the scan finishes in microseconds), both the listener AND the `alreadyComplete` branch would call `startOperation()`, dispatching the same copy/move/delete twice.
The symptom from an MCP-triggered 4.47 GB NAS→/tmp copy: two separate `copy_between_volumes` operations in the backend with different `operation_ids`, each streaming the full file. They serialized on the SMB session mutex, so the second one truncated `/tmp/<file>` back to zero and re-downloaded it — ~2× the wait time and memory pressure for the user. The UI path wasn't affected because manual Confirm takes long enough that `isScanning` is already false by then, and the dialog takes the direct `startOperation()` branch at onMount.
Fix: both paths now converge on a local `kickOff()` helper guarded by a `started` flag. Whoever wins the race calls `kickOff()` first, flips `started = true`, and the second call becomes a no-op. The error and cancelled listeners also flip `started = true` so a late `scan-preview-complete` can't dispatch an operation after we've decided to error/cancel.
No UX change: the same operation starts the same way on the same timeline; we just don't start it twice.1 parent 6f79392 commit 4af22ab
1 file changed
Lines changed: 23 additions & 7 deletions
Lines changed: 23 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
628 | 628 | | |
629 | 629 | | |
630 | 630 | | |
631 | | - | |
632 | | - | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
633 | 639 | | |
634 | 640 | | |
635 | 641 | | |
| |||
640 | 646 | | |
641 | 647 | | |
642 | 648 | | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
643 | 658 | | |
644 | 659 | | |
645 | 660 | | |
| |||
662 | 677 | | |
663 | 678 | | |
664 | 679 | | |
665 | | - | |
666 | | - | |
667 | | - | |
| 680 | + | |
668 | 681 | | |
669 | 682 | | |
670 | 683 | | |
671 | 684 | | |
672 | 685 | | |
673 | 686 | | |
| 687 | + | |
| 688 | + | |
674 | 689 | | |
675 | 690 | | |
676 | 691 | | |
| |||
685 | 700 | | |
686 | 701 | | |
687 | 702 | | |
| 703 | + | |
| 704 | + | |
688 | 705 | | |
689 | 706 | | |
690 | 707 | | |
| |||
698 | 715 | | |
699 | 716 | | |
700 | 717 | | |
701 | | - | |
702 | | - | |
| 718 | + | |
703 | 719 | | |
704 | 720 | | |
705 | 721 | | |
| |||
0 commit comments