Refresh Replaced Source Records After Import - #68
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a long-standing import deduplication bug where replacing a file’s contents at an existing source path would still leave the old hashes in Import.db, causing the “new” file to be re-imported on every subsequent run. The change aligns ImportTask’s “record the import” behavior with the already-correct IndexTask pattern, and adds a regression test to prove the database row is refreshed and the third run settles to a skip.
Changes:
- Update
ImportTaskto refresh an existing source-path row viaDatabase.UpdateHashesAsyncafter a successful import, instead of relying onINSERT OR IGNORE. - Add a three-run regression test covering “import → replace source content at same path → import → verify DB updated → next run skips”.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| PhotoCleaner/ImportTask.cs | Uses the pre-read source-path cache record to choose insert vs hash/metadata refresh after a successful import. |
| PhotoCleanerTests/ImportTaskTests.cs | Adds a regression test proving a replaced source file updates the existing DB row and the next run skips. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ptr727
marked this pull request as ready for review
August 18, 2026 18:32
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
Root Cause
Import recorded every successful file through
INSERT OR IGNORE. The source path is the primary key, so replacement content at an existing path left the old hashes unchanged and was imported again on every run.The update remains after destination processing succeeds. A failed import therefore cannot be recorded as imported.
Validation
dotnet csharpier format --log-level=debug .dotnet build --verbosity=minimal(0 warnings, 0 errors)dotnet format style --verify-no-changes --severity=info --verbosity=detaileddotnet test --no-build --verbosity=minimal(368 passed, 5 skipped, 0 failed)dotnet husky runRelated to #48.