BUG-133 - Harden RC1 Metadata Bounds, REST Polling, And Worker Shutdown Edges¶
Summary¶
Fix the concrete RC1 stabilization findings selected after the follow-up C++ hot-path and memory-safety review. The fixes cover malformed local metadata, high-frequency controller polling, shared transfer-detail scans, blocking DNS shutdown, shared-file hash worker exits, startup-cache save post failures, and part-file completion finalization during application shutdown.
Findings Addressed¶
- Local
known.metand.part.metmetadata could feed oversized file sizes or malformed tag payloads into later paths before rejecting the record. - Persistent tag counts and unknown tag retention were not bounded tightly enough for corrupt local metadata.
- AICH and MD4 part hashsets accepted inconsistent record counts before the remaining-byte checks had enough context.
- qBittorrent-compatible
/api/v2/torrents/inforebuilt and serialized the queue for each hot Arr poll even when the queue had not changed. - Native
/transfers/detailsrecomputed per-part source counts with a nested part-by-source scan on the UI-owned download queue. - The source hostname resolver could block inside DNS during shutdown while its worker still had access to object-owned state.
- Shared-file hashing and startup-cache workers could leave owner state stale when low-memory or post-message failure interrupted the normal completion path.
- Part-file completion could skip the success handoff after destructive moves once shutdown started.
Acceptance Criteria¶
- [x] Local metadata rejects impossible persisted file sizes before assigning them to known-file or part-file state.
- [x] Local metadata tag counts, malformed tag payloads, and retained unknown tags have explicit bounds.
- [x] Persisted AICH and MD4 hashsets reject count/remaining-byte mismatches.
- [x] qBittorrent-compatible torrent-info polling uses a bounded short-lived snapshot cache while preserving per-request category filtering.
- [x] Transfer detail part-source counts are computed in one source-list pass.
- [x] Hostname resolver shutdown uses detached shared state and a bounded stop path for blocking DNS calls.
- [x] Shared-file hashing and startup-cache save workers repair owner state when exception or UI post failure prevents the normal completion route.
- [x] Part-file completion still posts successful finalization after destructive filesystem cleanup even if shutdown starts.
Implementation Evidence¶
03089bd4BUG-133 harden local metadata completion integrity98658d3fBUG-133 reduce REST polling hot-path stalls87c33caaBUG-133 harden worker shutdown cleanup
Validation Evidence¶
git diff --check- Debug x64 app build through
python -m emule_workspace build app --variant main --config Debug --platform x64 --build-output-mode ErrorsOnly - Release x64 app build through
python -m emule_workspace build app --variant main --config Release --platform x64 --build-output-mode ErrorsOnly