refactor(repository): split repo.rs God file into sidecar + per-theme test modules#71
Merged
Merged
Conversation
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Splits the 1,694-line
src/repository/repo.rsGod file: filesystem side-effects move to a newsidecarmodule, and the embedded#[cfg(test)] mod testsis broken into per-theme files undersrc/repository/tests/. Production code inrepo.rsshrinks from 1,694 to 367 lines with no behavior change.Linked Issue
Closes #70
Changes
src/repository/sidecar.rshousingremove_image_files,remove_record_sidecars,remove_superseded_rich_text_files, andpurge_sidecar_dirsas plain free functions.repo.rsandcleanup.rsnow delegate filesystem work to it.fs::remove_dir_allerrors during schema migration /clearwithtracing::warn!so orphaned sidecar files no longer disappear without a trace (also addresses CODE_REVIEW §2.2).#[cfg(test)] mod testsout ofrepo.rsintosrc/repository/tests/{save,pin,dedup,display}_tests.rs, mounted via#[cfg(test)] mod tests;insrc/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.rsnow owns only postcard/redb encode/decode and its public API surface — 367 lines.Testing
scripts/precheck.shpasses locally (fmt,cargo check,cargo clippy -- -D warnings,cargo test,cargo machete, i18n / icons / themes).