Commit 5bcacfe
committed
Refactor: WriteFailure struct, shared kinds, dialog sub-components, copy threading
Four improvements that close the elegance gaps from the previous round, plus
the copy-side provider-enrichment threading.
WriteFailure struct (replaces MoveOpFailure tuple):
- New `pub(crate) struct WriteFailure { error, volume_ctx }` in volume_copy.rs
with two constructors: `from_volume(path, VolumeError)` (does the dual-use
clone in one place) and `synthetic(WriteOperationError)` (no volume context).
- Shared `write_error_event_from(...)` helper picks `with_friendly` or `new`
based on whether the failure carries volume context. Used by both move and
copy paths.
- Drops the per-call-site `e.clone()` boilerplate.
Copy-side threading:
- `copy_volumes_with_progress` now returns `Result<(), WriteFailure>` instead
of `Result<(), WriteOperationError>`. All `?` propagations updated, the two
`resolve_volume_conflict` sites map their WriteOperationError through
`WriteFailure::synthetic`, and the `copy_error: Option<WriteFailure>` carries
the originating VolumeError + path through to the outer emit.
- `copy_between_volumes` calls `write_error_event_from(...)` so cross-volume
copy failures get provider-enriched FriendlyError just like move (closes
the asymmetry the previous round documented).
- Two pre-existing test assertions updated to pattern-match the new
WriteFailure shape (sequential cancel, concurrent cancel/IoError tests).
Friendly content deduplication:
- New `friendly_error/kinds.rs` module holds canonical FriendlyError
constructors keyed by conceptual kind: not_found, permission_denied,
already_exists, cancelled, device_disconnected, read_only, storage_full,
connection_timeout, not_supported, io_serious.
- `volume_error.rs` shrank 184 → 49 lines, `write_error.rs` 189 → 139.
Both delegate to `kinds::*` for shared variants; variants with kind-specific
fields (InsufficientSpace's bytes, InvalidName's message, etc.) stay inline.
- `WriteOperationError::DeviceDisconnected` overrides `retry_hint` to true
after calling the kind helper (operation context — Retry button makes sense
for ops, not for listings).
TransferErrorDialog sub-components:
- Extracted `FriendlyErrorContent.svelte` (markdown rendering + anchor click
delegate to system-settings/external opener) and `FallbackErrorContent.svelte`
(variant-derived plain-text path) from the dialog.
- Dialog now just chooses between them based on `friendlyError` presence.
Renders title + icon + container colors at the dialog level, defers body
rendering to the appropriate child.
- 6 new tests for FriendlyErrorContent (markdown contract, anchor routing,
no-link no-crash safety net) — pins the component independently of the
dialog wrapper.
Tests: 1727 Svelte tests (+6 new), 1571 Rust unit, 28 integration. Full
`./scripts/check.sh` green; `claude-md-reminder` clean.1 parent 51dff4c commit 5bcacfe
11 files changed
Lines changed: 698 additions & 490 deletions
File tree
- apps/desktop
- src-tauri/src/file_system
- volume/friendly_error
- write_operations
- src/lib/file-operations/transfer
Lines changed: 201 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
0 commit comments