Commit ccb2708
fix(#187 AC#2): cancel through verify/install + stale partial + dead code
Four findings from Copilot's re-review of the security/correctness fixes:
- **Cancel couldn't stop verify/install**: the runner removed the
inFlight handle BEFORE verification, so cancelDownload() couldn't
abort SHA-256 or rename. After verify completed, the runner would
overwrite the user's cancelled status with complete/failed. Now
the handle stays in inFlight through verify+install, and the runner
checks handle.cancelled at every phase boundary (pre-verify,
post-hash, pre-install, post-rename) and bails without writing
terminal status if cancel fired. inFlight.delete moved to the
final boundary.
- **Stale .partial corrupting fresh resume**: a previous attempt that
failed to delete .partial (e.g., Windows file lock during cancel)
could cause a brand-new download row to "resume" from stale bytes.
Now we only resume when bytes_downloaded > 0 on the row; otherwise
we delete any pre-existing partial before starting fresh.
- **UI showed Pause for verifying/installing but backend rejected it**:
pauseDownload() returns ok:false for those statuses. Added
PAUSABLE_STATUSES set (pending + downloading only); the action
bar shows Cancel-only during verify/install. Cancel now actually
works through those phases (per the runner change above).
- **ensureDirectory() dead code**: exported but unused. Removed,
along with the now-unused `dirname` import.
Build clean. 25 route tests passing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 255d446 commit ccb2708
2 files changed
Lines changed: 44 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
221 | 226 | | |
222 | | - | |
| 227 | + | |
223 | 228 | | |
224 | 229 | | |
225 | 230 | | |
226 | 231 | | |
227 | 232 | | |
| 233 | + | |
| 234 | + | |
228 | 235 | | |
229 | 236 | | |
230 | 237 | | |
| |||
336 | 343 | | |
337 | 344 | | |
338 | 345 | | |
339 | | - | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
340 | 353 | | |
341 | 354 | | |
342 | 355 | | |
| |||
352 | 365 | | |
353 | 366 | | |
354 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
355 | 375 | | |
356 | 376 | | |
357 | 377 | | |
358 | 378 | | |
| 379 | + | |
359 | 380 | | |
360 | 381 | | |
361 | 382 | | |
| |||
364 | 385 | | |
365 | 386 | | |
366 | 387 | | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
367 | 392 | | |
368 | 393 | | |
369 | 394 | | |
370 | 395 | | |
371 | 396 | | |
372 | 397 | | |
| 398 | + | |
| 399 | + | |
373 | 400 | | |
374 | 401 | | |
375 | 402 | | |
376 | 403 | | |
377 | 404 | | |
378 | 405 | | |
| 406 | + | |
| 407 | + | |
379 | 408 | | |
380 | 409 | | |
381 | 410 | | |
| |||
403 | 432 | | |
404 | 433 | | |
405 | 434 | | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | 435 | | |
416 | 436 | | |
417 | 437 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
39 | 46 | | |
40 | 47 | | |
41 | 48 | | |
| |||
94 | 101 | | |
95 | 102 | | |
96 | 103 | | |
| 104 | + | |
97 | 105 | | |
98 | 106 | | |
99 | 107 | | |
100 | 108 | | |
101 | 109 | | |
102 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
103 | 114 | | |
104 | 115 | | |
105 | 116 | | |
| |||
0 commit comments