S006: download manager, events and snapshots

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-25 02:34:27 -06:00
commit 548fcb27b5

View file

@ -77,5 +77,15 @@ Verified: `--test visuals` green (bounds and NaN at every look, speed, width and
- `badge`: `Kind` comes from the category; nothing maps names to kinds yet. `loading` shows only after 0.3 s; draw it for as long as something is waited for.
Not done: the map has no keyboard focus (its numbers belong in the detail list too). Not seen on a real GPU or by hand: the feel of the springs. `wave::slider` is the wavy one for limits, S013's is the plain one.
## S006 — Download manager, events and snapshots (2026-11-25)
Done: `core::manager` (thread, commands, who runs, file work, bin), `snapshot`, `events`, `speed`; `cargo run -p medlar-core --example manager` shows text progress. Choices: D-029, D-030. Outside the plan's files: `Store::edit_task` and `used_names`, `disk` (free names), `http/download.rs` (uses them).
Verified: `nice cargo test -j 2 -p medlar-core` green (76 unit, 16 http, 12 manager, 9 parts); the 10,000-command fuzz 100 of 100 times on an overloaded CPU; clippy clean for the new code. Debug build, 10,000 tasks: open 0.5 s, reading a snapshot 0.15 µs, sending 10,000 commands 4 ms, one change copies one view. 12 downloads close in under 2 s without losing a byte.
- One `Manager` per program, in an `Arc`: `Manager::open(Config::new(Shared, limits))`, not on the window's thread. `send(Command) -> Reply` never waits; `Reply` is a future, `try_get()` for the window, `wait()` for plain threads. It comes after the snapshot shows the change. Drop it to ignore errors.
- `Command::{Add, Start, Pause, Resume, Stop, Remove{id,files}, Restore, Redownload, Move{id,folder}, Rename{id,name}, Edit{id,edit}}`; `Edit` covers all the user decides (priority, position, queue, notes, limits…). `set_limits(settings.limits())` is live.
- `snapshot() -> Arc<Snapshot>`: `rev`, `totals`, `iter()` by id, `get(id)`, `changed_since(rev)`. `TaskView`: `task`, `size`, `downloaded`, `speed`, `left`, `parts` (`PartView`), `connections`, `wanted`, `resumable`, `checked` (0 for now), `server`, `history` (300 s; `pushed()` tells what is new), `log` (200 lines), `counters`. `on_change(f)` is for `request_repaint`; nothing is published while nothing changes. `subscribe()` gives `Event`s.
- `begin_close()` doesn't wait; `close()` and drop do (under 2 s). Error text of `http::Error` is raw: S007 fills `words()` and the kinds at the end of `manager/actor.rs`; Retry-After and Waiting are its too.
Not done: part events (`Split`…) don't leave the manager; `PartView.id` tells parts apart within a run. Counters and logs are for this session only. Cookies and logins from the keyring are not added to `Source` yet. Queue `paused`, `max_active`, `schedule`, `after`, `start_at` are not looked at (S009); Done files are not checked for being gone; `Only` does not pause what can't resume.
Seen: connections of a host are first come, first served: with more downloads than fit, some run without any until others end (S010). `http::name::no_name_gets_out_of_its_folder` took over 60 s on an overloaded CPU. Boxes were ticked together at the end, against rule 3.
## Later
-