Current State
src/repository/repo.rs is currently a 1,694-line file. Roughly 460 lines are production logic; the remaining ~1,300 lines are #[cfg(test)] test cases embedded in the same file. The file simultaneously handles repository construction, schema migration, save/get/delete/clear, pin logic, dedup, and rich-text/image sidecar file management.
Target State
- Tests are split by theme into
src/repository/tests/{save,pin,dedup,display}_tests.rs, mounted via #[cfg(test)] mod tests; in src/repository/mod.rs.
- Filesystem sidecar helpers (
remove_image_files, remove_record_sidecars, remove_superseded_rich_text_files, schema-migration / clear directory cleanup) live in a new src/repository/sidecar.rs as free functions.
repo.rs is responsible only for DB encode/decode and delegates filesystem side-effects to sidecar.
Rationale
- A single test edit currently recompiles the entire 1.7k-line file → slow incremental builds.
- Adding a new
ContentType requires reading the whole file to feel safe — high cognitive overhead.
- Mixing DB logic with filesystem side-effects makes both harder to reason about and test in isolation.
This is item §1.1 ("src/repository/repo.rs — God File ⚠️ High Priority") in doc/CODE_REVIEW.md.
Acceptance Criteria
Scope
repository
Current State
src/repository/repo.rsis currently a 1,694-line file. Roughly 460 lines are production logic; the remaining ~1,300 lines are#[cfg(test)]test cases embedded in the same file. The file simultaneously handles repository construction, schema migration,save/get/delete/clear, pin logic, dedup, and rich-text/image sidecar file management.Target State
src/repository/tests/{save,pin,dedup,display}_tests.rs, mounted via#[cfg(test)] mod tests;insrc/repository/mod.rs.remove_image_files,remove_record_sidecars,remove_superseded_rich_text_files, schema-migration /cleardirectory cleanup) live in a newsrc/repository/sidecar.rsas free functions.repo.rsis responsible only for DB encode/decode and delegates filesystem side-effects tosidecar.Rationale
ContentTyperequires reading the whole file to feel safe — high cognitive overhead.This is item §1.1 ("⚠️ High Priority") in
src/repository/repo.rs— God Filedoc/CODE_REVIEW.md.Acceptance Criteria
repo.rsproduction code stays ≤ ~500 lines and contains no embedded test module.src/repository/sidecar.rsexists and owns all sidecar filesystem helpers as free functions.src/repository/tests/{save,pin,dedup,display}_tests.rs.scripts/precheck.shpasses (fmt / check / clippy-D warnings/ test / machete / i18n / icons / themes).Scope
repository