Medlar/Plans/02 Engine/S008-continue-links.md
2026-11-25 05:52:10 -06:00

1.8 KiB

S008 — Continue from a new link

Category 02 Engine · Model: Opus · Effort: high · Depends on: S007 · Size: M · Human: no Files touched: crates/core/src/{relink,adopt}, crates/core/tests/relink

Goal

An expired or dead download carries on from a fresh link, and partial files can be picked up. FEATURES 1.12, 4.6 (matching), 7.8.

Read

  • crates/core/src/{error,disk,segment,manager}*
  • docs/FEATURES.md 1.12, 4.6, 7.8

Steps

  • Relink command: probe the new link, compare length and validators, then compare sampled finished ranges and the edges byte for byte before accepting
  • Verdicts: same file, probably same (no validators, samples equal), different, cannot tell; each with its message; never continues on "different"
  • Headers, cookies, referrer and login replaced with the new link's; old ones dropped
  • Server without ranges: explain that it must start over, keep the old partial until the new one is done
  • Matcher: given an incoming link (and name, size, page), rank unfinished downloads it may continue; signed-URL query noise ignored; tests with realistic CDN links
  • Adopt a partial file: plain truncated file from a browser (.part, .crdownload), and other managers' partials when the part list is readable and documented; otherwise treat the start of the file as finished only after a byte check
  • Expired link on the source page: "open source page" state that waits for a matching link
  • docs/PROGRESS.md entry, tick Plans/INDEX.md, commit S008: …, push

End criteria

  • nice cargo test -j 2 -p medlar-core --test relink green: expiring links, swapped content, same size but different bytes, no validators

Pitfalls

Equal size and name is not the same file. Sampling must include the last finished bytes.

Handoff (→ PROGRESS.md)

Matcher API for S016 and S024.