Commit b401889
committed
Delete: emit write-cancelled when scan phase aborts
`scan_volume_recursive`'s top-of-function cancel check returned `Err(Cancelled)` without emitting the terminal event, so a mid-scan cancel of a volume delete propagated up silently and the FE never saw `write-cancelled`. With M4's settle event in place the dialog still closed via the safety-net path, but the selection-recovery / log trail / dialog state-machine all want the proper event.
The cancel check fires at every recursion level, so emitting from inside `scan_volume_recursive` would multi-fire. Instead: add a small `emit_cancelled_if_aborted` helper next to the entry point, call it at each of the three `scan_volume_recursive(...).await?` sites in `delete_volume_files_with_progress_inner`. The pattern mirrors the five existing emit-then-return cancel sites elsewhere in the file.
Regression test in `delete_volume_reuse_tests.rs` pre-sets `state.intent` to `Stopped`, runs a delete, asserts the result is `Cancelled` AND the event sink received a `write-cancelled` with `rolled_back: false`.1 parent f894e60 commit b401889
2 files changed
Lines changed: 97 additions & 8 deletions
File tree
- apps/desktop/src-tauri/src/file_system/write_operations
Lines changed: 38 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
226 | 232 | | |
227 | 233 | | |
228 | 234 | | |
| |||
409 | 415 | | |
410 | 416 | | |
411 | 417 | | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
412 | 438 | | |
413 | 439 | | |
414 | 440 | | |
| |||
506 | 532 | | |
507 | 533 | | |
508 | 534 | | |
509 | | - | |
| 535 | + | |
510 | 536 | | |
511 | 537 | | |
512 | 538 | | |
| |||
518 | 544 | | |
519 | 545 | | |
520 | 546 | | |
521 | | - | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
522 | 550 | | |
523 | 551 | | |
524 | 552 | | |
525 | 553 | | |
526 | 554 | | |
527 | | - | |
| 555 | + | |
528 | 556 | | |
529 | 557 | | |
530 | 558 | | |
| |||
536 | 564 | | |
537 | 565 | | |
538 | 566 | | |
539 | | - | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
540 | 570 | | |
541 | 571 | | |
542 | 572 | | |
| |||
600 | 630 | | |
601 | 631 | | |
602 | 632 | | |
603 | | - | |
| 633 | + | |
604 | 634 | | |
605 | 635 | | |
606 | 636 | | |
| |||
612 | 642 | | |
613 | 643 | | |
614 | 644 | | |
615 | | - | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
616 | 648 | | |
617 | 649 | | |
618 | 650 | | |
| |||
Lines changed: 59 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
| 19 | + | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
0 commit comments