Skip to content

Fix library duplicate matching for Local browse records - #1433

Closed
Clearfall wants to merge 1 commit into
storytold:mainfrom
Clearfall:fix/local-browse-import-duplicates
Closed

Clearfall wants to merge 1 commit into
storytold:mainfrom
Clearfall:fix/local-browse-import-duplicates

Conversation

@Clearfall

@Clearfall Clearfall commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem and change

Browsing a byte-identical copy in Local could make an import incorrectly report “already in the library”, even after the library photo had been permanently deleted and the library reopened. Conversely, importing a browsed copy could promote it before checking for an existing library photo with the same content.

Exclude Local-only records from the library content index, prefer the actual library photo (including the existing trash restore/skip policy), and register a promoted hash immediately so later files and worker batches are deduplicated. Browsed records and original files are retained.

Validation

AI-assisted contribution, reviewed and tested for @Clearfall. Kept as a draft while final validation is incomplete.

Publication checkpoint (2026-10-14)

Upstream main advanced to a4b53b2. This branch remains based on 68c9240, and GitHub reports conflicts in crates/engine/src/import.rs and docs/parity-checklist.md. The upstream import indexing refactor still includes Local-only records in content matching; it does not supersede this bug fix. Rebase/conflict resolution and current-main validation remain required before leaving draft status. Separate drafts: #1713 (Lens Blur) and #1714 (conventional NR comparison).

…ching

Prefer real library entries when importing browsed copies and track promoted hashes across scan and background-import batches. Add synthetic regressions for permanent deletion, restart, trash restoration, and duplicate promotion.

Draft validation on the previous base: 59 import tests passed; all 8 cargo xtask ci steps passed with PR storytold#1052 in a temporary validation worktree. Rebased onto main 68c9240, which includes storytold#1052; validation of this base is recorded in the PR.

Co-authored-by: Codex <noreply@openai.com>
@nledford

Copy link
Copy Markdown
Contributor

Hi @Clearfall, thanks for this fix. I ran into the same bug from the other side: a folder menu I'm adding (#2961, Add to My Photos… on a Local folder) opens the Import review, and on current main the scan still reports a browsed Local photo's own file as duplicate "path", so the review shows it "In library" and it can't be checked.

This branch no longer merges with main (the scan's path table moved into library_files in crates/engine/src/import.rs, with conflicts in tests_import.rs and the parity checklist). So I'm porting your approach onto current main in a PR of its own: keep Local-only records out of the path duplicates and the content index, check for a real library match before a browsed copy is promoted, and port your tests that still apply. You'll be credited as Co-authored-by on the commit. I'll link the PR here when it's open, and I'll point out anything it does differently from yours. If you'd rather rebase this one yourself, say so and I'll build on yours instead.

@nledford

Copy link
Copy Markdown
Contributor

The port is open as #2971, with you as Co-authored-by. It carries your four engine tests, adapted to today's library_files. Where it goes further than this PR: a browsed candidate is marked (ImportCandidate.local) so the Import review can offer it when adding in place, "Import as new" replaces a trashed twin, a restore doesn't relink onto a browsed path, and Synchronize doesn't take a browsed file as a moved photo's new place. If anything in yours is missing there, I'd be glad to hear it.

nledford added a commit to nledford/lightcraft that referenced this pull request Oct 26, 2026
…nger blocks the library's own file

The scan listed a file that was only browsed in Local as a duplicate by path, so the Import review showed it "In library" and out of reach, and a browsed copy under another path counted as library content. Only library records now count as existing content: a browsed file is offered (still naming its record) and importing it promotes that record with its edits, a library photo with the same content is matched before a browsed copy is promoted, and promoted content counts across scan and background import batches.

The review offers such a file only when adding in place, since copy and move would add it where it is, and says that keywords and presets apply to new files only.

Ports the approach and the engine tests of storytold#1433 to current main.

Co-authored-by: Clearfall <237151555+Clearfall@users.noreply.github.com>
nledford added a commit to nledford/lightcraft that referenced this pull request Oct 27, 2026
…nger blocks the library's own file

The scan listed a file that was only browsed in Local as a duplicate by path, so the Import review showed it "In library" and out of reach, and a browsed copy under another path counted as library content. Only library records now count as existing content: a browsed file is offered (still naming its record) and importing it promotes that record with its edits, a library photo with the same content is matched before a browsed copy is promoted, and promoted content counts across scan and background import batches.

The review offers such a file only when adding in place, since copy and move would add it where it is, and says that keywords and presets apply to new files only.

Ports the approach and the engine tests of storytold#1433 to current main.

Co-authored-by: Clearfall <237151555+Clearfall@users.noreply.github.com>
nledford added a commit to nledford/lightcraft that referenced this pull request Nov 2, 2026
…nger blocks the library's own file

The scan listed a file that was only browsed in Local as a duplicate by path, so the Import review showed it "In library" and out of reach, and a browsed copy under another path counted as library content. Only library records now count as existing content: a browsed file is offered (still naming its record) and importing it promotes that record with its edits, a library photo with the same content is matched before a browsed copy is promoted, and promoted content counts across scan and background import batches.

The review offers such a file only when adding in place, since copy and move would add it where it is, and says that keywords and presets apply to new files only.

Ports the approach and the engine tests of storytold#1433 to current main.

Co-authored-by: Clearfall <237151555+Clearfall@users.noreply.github.com>
nledford added a commit to nledford/lightcraft that referenced this pull request Nov 5, 2026
…nger blocks the library's own file

The scan listed a file that was only browsed in Local as a duplicate by path, so the Import review showed it "In library" and out of reach, and a browsed copy under another path counted as library content. Only library records now count as existing content: a browsed file is offered (still naming its record) and importing it promotes that record with its edits, a library photo with the same content is matched before a browsed copy is promoted, and promoted content counts across scan and background import batches.

The review offers such a file only when adding in place, since copy and move would add it where it is, and says that keywords and presets apply to new files only.

Ports the approach and the engine tests of storytold#1433 to current main.

Co-authored-by: Clearfall <237151555+Clearfall@users.noreply.github.com>
nledford added a commit to nledford/lightcraft that referenced this pull request Nov 6, 2026
…nger blocks the library's own file

The scan listed a file that was only browsed in Local as a duplicate by path, so the Import review showed it "In library" and out of reach, and a browsed copy under another path counted as library content. Only library records now count as existing content: a browsed file is offered (still naming its record) and importing it promotes that record with its edits, a library photo with the same content is matched before a browsed copy is promoted, and promoted content counts across scan and background import batches.

The review offers such a file only when adding in place, since copy and move would add it where it is, and says that keywords and presets apply to new files only.

Ports the approach and the engine tests of storytold#1433 to current main.

Co-authored-by: Clearfall <237151555+Clearfall@users.noreply.github.com>
@wanikhawar

Copy link
Copy Markdown
Contributor

This is already on main through #2971, with the same local_twin_* regression tests. Please close it unless there is a case #2971 misses.

@FredApps

FredApps commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Thank you @Clearfall. This fix landed on main through #2971 (a photo browsed in Local is offered by Import), which ports this PR to current main and extends it to the Import review, with the same local_twin-style regression tests in crates/engine/src/tests/import.rs. Closing; if there is a case #2971 misses, please open a fresh PR.

@FredApps FredApps closed this Dec 3, 2026
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.

4 participants