Commit 35120da
committed
SMB: Stream uploads, bound copy memory
- `SmbVolume::import_single_file_with_progress` used to `std::fs::read` the full local source into a `Vec<u8>` before writing. An 8 GB local→NAS copy meant 8 GB of RAM. Now opens the source with `tokio::fs::File::open` and drives smb2's `FileWriter` chunk-by-chunk (~1 MiB buffer).
- `SmbVolume::write_from_stream` used to drain the incoming `VolumeReadStream` into `all_data: Vec<u8>` before a single `write_file_pipelined`. Now pulls from `stream.next_chunk().await` and pushes each chunk straight into `FileWriter`. The old "don't hold the smb mutex across source reads" concern was overblown — different volumes have different mutexes, and `export_single_file_with_progress` already holds the lock for the read duration.
- Both paths now report `VolumeError::Cancelled` on `ControlFlow::Break(())` (matching the shared cancel-as-Cancelled rule) and finalize the writer to drain in-flight pipelined WRITE responses before deleting the partial file, so the session stays usable for subsequent ops.
- Added a `# Streaming requirement` section to the `export_to_local`, `import_from_local`, `open_read_stream`, `write_from_stream` doc comments on the `Volume` trait, calling out the ~1 MiB peak-RAM budget and the anti-pattern of pre-buffering.
- Updated `volume/CLAUDE.md`: flipped the `write_from_stream` row to ✅, amended `import_from_local` to note streaming in both directions, rewrote the "Anti-pattern" section, and added a tier 2 checklist bullet pointing at the new trait doc sections.
- Added three Docker-integration tests: `smb_integration_import_from_local_streams_large_file`, `smb_integration_write_from_stream_streams_large_file`, `smb_integration_import_from_local_cancel_mid_write`. Existing streaming integration tests still pass.
- Bumped the file-length allowlist for `smb.rs` (now 2670).1 parent 33300a4 commit 35120da
4 files changed
Lines changed: 306 additions & 39 deletions
File tree
- apps/desktop/src-tauri/src/file_system/volume
- scripts/check/checks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| |||
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
107 | | - | |
| 108 | + | |
108 | 109 | | |
109 | 110 | | |
110 | | - | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| |||
154 | 155 | | |
155 | 156 | | |
156 | 157 | | |
157 | | - | |
| 158 | + | |
158 | 159 | | |
159 | 160 | | |
160 | 161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
508 | 508 | | |
509 | 509 | | |
510 | 510 | | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
511 | 523 | | |
512 | 524 | | |
513 | 525 | | |
| |||
524 | 536 | | |
525 | 537 | | |
526 | 538 | | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
527 | 552 | | |
528 | 553 | | |
529 | 554 | | |
| |||
580 | 605 | | |
581 | 606 | | |
582 | 607 | | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
583 | 622 | | |
584 | 623 | | |
585 | 624 | | |
| |||
602 | 641 | | |
603 | 642 | | |
604 | 643 | | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
605 | 658 | | |
606 | 659 | | |
607 | 660 | | |
| |||
0 commit comments