fix(history): make write() thread-safe

Guard DownloadHistory.write() with a threading.Lock so concurrent
worker threads do not corrupt or lose history entries during parallel
downloads. Lock wraps both _data mutation and disk flush; read-only
methods (is_downloaded, find) stay lock-free per CPython dict atomicity.

Closes #13
This commit is contained in:
AlexKucera committed 2026-06-03 17:15:57 +02:00
1 parent 2547bd1f22
commit a18232c063
5 files changed
+214 -3

No files matched your search

+7
View File
@@ -14,6 +14,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
against implementation. Polished README with badges, features table, format
comparison, and project comparison note.
### Fixed
- **history:** Make `DownloadHistory.write()` thread-safe with
`threading.Lock` so concurrent worker threads don't corrupt or lose
history entries during parallel downloads. Lock guards both in-memory
mutation and disk flush. 5 new tests (184 total) (closes #13)
### Added
- **config:** Parallel download worker count: `workers` field on Config dataclass
(default 3), `InvalidWorkersError` validation for values < 1, YAML parsing