Skip to content

refactor(repository): split repo.rs God file into sidecar + per-theme test modules#71

Merged
StudentWeis merged 1 commit into
mainfrom
refactor/70-split-repo-god-file
May 6, 2026
Merged

refactor(repository): split repo.rs God file into sidecar + per-theme test modules#71
StudentWeis merged 1 commit into
mainfrom
refactor/70-split-repo-god-file

Conversation

@StudentWeis
Copy link
Copy Markdown
Owner

Summary

Splits the 1,694-line src/repository/repo.rs God file: filesystem side-effects move to a new sidecar module, and the embedded #[cfg(test)] mod tests is broken into per-theme files under src/repository/tests/. Production code in repo.rs shrinks from 1,694 to 367 lines with no behavior change.

Linked Issue

Closes #70

Changes

  • Add src/repository/sidecar.rs housing remove_image_files, remove_record_sidecars, remove_superseded_rich_text_files, and purge_sidecar_dirs as plain free functions. repo.rs and cleanup.rs now delegate filesystem work to it.
  • Replace silently-discarded fs::remove_dir_all errors during schema migration / clear with tracing::warn! so orphaned sidecar files no longer disappear without a trace (also addresses CODE_REVIEW §2.2).
  • Move #[cfg(test)] mod tests out of repo.rs into src/repository/tests/{save,pin,dedup,display}_tests.rs, mounted via #[cfg(test)] mod tests; in src/repository/mod.rs. Each test file carries its own #![cfg_attr(test, allow(clippy::expect_used, clippy::unwrap_used))] to match the original allow scope.
  • repo.rs now owns only postcard/redb encode/decode and its public API surface — 367 lines.

Testing

  • scripts/precheck.sh passes locally (fmt, cargo check, cargo clippy -- -D warnings, cargo test, cargo machete, i18n / icons / themes).
  • All 411 existing tests still pass without assertion changes — pure mechanical refactor.

… test modules

- Extract filesystem side-effects (image/thumbnail removal, rich-text sidecar
  cleanup, schema-migration / clear directory purge) from repo.rs into a new
  src/repository/sidecar.rs as plain free functions. repo.rs now owns only
  the postcard/redb encode/decode path and delegates filesystem work.
- Move the embedded #[cfg(test)] mod tests out of repo.rs into per-theme
  files under src/repository/tests/{save,pin,dedup,display}_tests.rs so a
  single test edit no longer recompiles the whole 1.7k-line translation unit.
- Replace silently-discarded fs::remove_dir_all errors during schema
  migration / clear with tracing::warn! so orphaned sidecar files are no
  longer dropped without a trace.
- repo.rs shrinks from 1694 to 367 lines; production behavior is unchanged
  and all 411 existing tests still pass.

Refs #70
@StudentWeis StudentWeis merged commit b0c3017 into main May 6, 2026
8 checks passed
@StudentWeis StudentWeis deleted the refactor/70-split-repo-god-file branch May 6, 2026 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: split repo.rs God file into sidecar + per-theme test modules

1 participant