Skip to content

Promote Rename Collision, Odd GIF, HEIF Pairing, and Image-Hash Matching to Main - #289

Merged
ptr727 merged 4 commits into
mainfrom
develop
Nov 18, 2026
Merged

ptr727 merged 4 commits into
mainfrom
develop

Conversation

@ptr727

@ptr727 ptr727 commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Promotes four feature pull requests and one Dependabot bump from develop to main.

PR Change Closes
#286 process renames onto a free _N name instead of deleting the file holding the target name, and pads odd GIF dimensions to even for libx264 #280, #281
#287 .heif counts as a Live Photo companion still, with and without --db #276
#288 Opt-in --imagehash matching for import dedup and the Immich trash match, plus trash --processdb to record image hashes #278
#285 Dependabot nuget-deps bump on develop none

Fixes #276
Fixes #278
Fixes #280
Fixes #281

#277 stays open, blocked on ptr727/ProjectTemplate#4265.

🤖 Generated with Claude Code

dependabot Bot and others added 4 commits November 18, 2026 10:57
Bumps Serilog.Extensions.Logging from 10.0.0 to 11.0.0

---
updated-dependencies:
- dependency-name: Serilog.Extensions.Logging
  dependency-version: 11.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: nuget-deps
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Rename to a Free Name on Collision and Pad Odd GIF Dimensions

An extension rename in `process` no longer deletes or backs up a file
already holding its target name. The renamed file takes the next free
`_N` name, the way `import` does, and a warning names both files. This
holds with and without `--skipbackup`. The extension-conflict deferral in
ProcessCommand only kept same-stem files out of one parallel pass, so it
never reserved the name on disk.

The re-encode tier pads to even dimensions with
`pad=ceil(iw/2)*2:ceil(ih/2)*2`, since libx264 at yuv420p rejects an odd
width or height.

GUIDE.md drops both known-issue entries, and ARCHITECTURE.md describes
the new behaviour.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep a Same-Name Conversion Output Under --skipbackup

With `--skipbackup` the original stayed on disk while the output name
was chosen, so a PCM `.mp4` collided with itself and its output became
`_1.mp4`. The original now moves to its `.bak` name in both modes, and
`--skipbackup` deletes that `.bak` once its metadata is copied.

BackupFile's rename now goes through RenameFile, and the padding comment
names a column as well as a row. A test covers a case-only rename on a
case-insensitive filesystem, skipped where the filesystem is
case-sensitive.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Describe Rename Collisions and GIF Padding in the README

The README now says a renamed file takes the next free name when its
target is taken, that `--skipbackup` leaves no `.bak` behind, and that
the re-encode pads to even dimensions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Correct the README Mixed-Case Extension Example

Only an extension mixing upper and lower case is lowercased, so `.Jpg`
becomes `.jpg` and an all-uppercase `.JPG` is kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* State What the Even-Dimension Pad Keeps

A GIF keeps every pixel under the pad. An odd-sized subsampled source,
such as a yuv420p AVI, loses its last odd row or column to the pad
color, so the docs and the comment no longer claim every pixel is kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
* Accept .heif as a Live Photo Companion Still

Add .heif to the companion extension list so a still cataloged as .heif
and renamed to .heic in the same round still pairs with its video, for
both the --db lookup and the same-folder search.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* Name HEIF in the Live Photo Companion Comment

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

---------

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
* Match by Image-Data Hash for Import Dedup and the Immich Trash

Add an opt-in --imagehash option to import and process, and an optional
--processdb option to trash, so a copy that differs only in metadata can
be matched by its image data hash. Default runs keep whole-file matching.

- import --imagehash skips a source whose image data hash is in --db and
  logs the matched row, and skips one whose hash is in --trashdb.
- process --imagehash deletes a file whose cataloged image data hash is
  in --trashdb.
- trash --processdb records each trashed asset's image data hash, looked
  up by SHA-1 in a read-only process database.
- The trash database gains an image_hash column, upgraded in place.
- A null or empty image hash never matches.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Address Local Review Findings on Image-Data Hash Matching

- trash --processdb backfills every row without an image hash, so rows
  of assets already purged from the server gain one too.
- import claims each hash for the run, so two matching files handled in
  parallel import once, by SHA-256 and by image hash under --imagehash.
- --processdb is a command-line field read by CreateOptions, and a test
  covers its wiring to Options.DbFile.
- Trash and process databases share one column-name helper.
- Drop the empty-string guards no writer needs.
- Docs warn that a trashed copy's image hash also matches a kept copy,
  and no longer suggest index for backfilling an import database.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Release an Import Claim When Its File Does Not Import

A file that claimed a hash and then failed or proved invalid kept the
claim, so a later match in the same run was skipped although nothing was
imported. The claims are now released on any outcome but Imported.

Drop the unreachable read-only guard from FindPathByImageHashAsync, whose
only caller opens the import database read-write and already rejects an
empty hash.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Wait on a Claim's Outcome and Share the Existing-File Validator

A file that met another file's claim was skipped at once, so a winner
that then failed or proved invalid left both files unimported. A file
now waits for the claim owner's outcome, skipping when the owner
imported and claiming again when the owner released it. SHA-256 is
always claimed before the image hash, and no file waits while holding an
image hash, so the waits cannot form a cycle.

The file-exists validators for --trashdb, --skipdb, --processdb, and
--apikey-file move onto one CreateExistingFileOption factory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Correct Claim Docs and Make the Parallel Claim Test Order-Independent

- The parallel case of the claim-release test asserts only the outcome
  both claim orders share.
- Drop a claim branch that no enumerated run can reach.
- GUIDE no longer says identical files in one parallel run may both
  import, since the claim set imports one.
- The restored-asset note no longer advises deleting sibling rows, which
  a later trash sync refills. It says to leave --imagehash off instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Add the New Option Names to the Spelling Word List

Add imagehash and processdb beside trashdb and skipdb, so the spell
check accepts the new --imagehash and --processdb options.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Check ExifTool Up Front for Import Image Hashes and Test Claim Waits

- import --imagehash checks the ExifTool version once before the run,
  so a trash-only import with an old ExifTool stops with one message
  instead of failing every file.
- The claim comment and ARCHITECTURE say only the counts match a
  sequential run, since which matching file imports depends on timing.
- ClaimedByAsync and the extracted ReleaseClaims are internal, and new
  tests cover a waiter on a running owner that releases and one that
  imports, and a cancelled waiter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Test the Trash Upsert Contract and Drop a Timing-Dependent Test Row

- A test asserts that a later upsert keeps a stored name and image hash
  and fills a missing hash.
- The claim-release import test runs on one thread only, since its
  parallel row passed in either claim order; ClaimedByAsync tests cover
  the wait deterministically.
- Correct the GetFileMetaAsync comment, which an image-hash import
  without a database also reaches.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Correct a Trash Test Comment the Upsert Made Stale

The duplicate-hash test said INSERT OR IGNORE deduplicates, but the
trash insert is now an upsert on sha1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Cover Image-Hash Twins When Un-Marking an Import Row

The GUIDE step for un-marking files in a seeded import database named
only SHA-256 twins. With --imagehash, a row sharing the image hash still
skips the file, so the step now says to run that import without the
option or delete those rows too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings November 18, 2026 22:01
@coderabbitai

coderabbitai Bot commented Nov 18, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.55906% with 241 lines in your changes missing coverage. Please review.
✅ Project coverage is 41.73%. Comparing base (64380a0) to head (3731ff9).
⚠️ Report is 166 commits behind head on main.

Files with missing lines Patch % Lines
PhotoCleaner/ImportTask.cs 0.00% 124 Missing ⚠️
PhotoCleaner/ProcessTask.cs 0.00% 68 Missing ⚠️
PhotoCleaner/TrashCommand.cs 80.59% 21 Missing and 5 partials ⚠️
PhotoCleaner/TrashDatabase.cs 88.31% 7 Missing and 2 partials ⚠️
PhotoCleaner/ImportCommand.cs 0.00% 8 Missing ⚠️
PhotoCleaner/ProcessCommand.cs 0.00% 5 Missing ⚠️
PhotoCleaner/CommandLine.cs 98.11% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #289      +/-   ##
==========================================
+ Coverage   41.25%   41.73%   +0.48%     
==========================================
  Files          27       27              
  Lines        4138     4445     +307     
  Branches      362      390      +28     
==========================================
+ Hits         1707     1855     +148     
- Misses       2361     2520     +159     
  Partials       70       70              
Flag Coverage Δ
dotnet 41.73% <52.55%> (+0.48%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An active finding remains because the Live Photo comment omits the supported .jpg companion format, making the documentation inaccurate.

1 open issue
What changed in this PR

Promotes collision-safe renaming, odd-dimension video padding, HEIF Live Photo pairing, opt-in image-hash matching, trash database backfilling, and the Serilog dependency update to main.

Changes:

  • Prevents extension-renaming collisions from displacing existing files and pads odd video dimensions for libx264 conversion.
  • Adds .heif Live Photo pairing and opt-in --imagehash and --processdb workflows with schema upgrades.
  • Expands database handling, concurrency claims, tests, and operational documentation for the new features.
  • Updates Serilog.Extensions.Logging to 11.0.0.
File Description
README.md Documents image-hash matching, process collision handling, HEIF pairing, and padded video conversion.
PhotoCleanerTests/​TrashDatabaseTests.cs Tests trash schema migration, image-hash lookups, and upsert behavior.
PhotoCleanerTests/​TrashCommandTests.cs Tests process-database image-hash recording and backfilling during trash synchronization.
PhotoCleanerTests/​ProcessTaskTests.cs Tests collision-safe renames, odd-dimension conversion, skip-backup conversion, and image-hash trash matching.
PhotoCleanerTests/​LivePhotoCatalogTests.cs Tests HEIF Live Photo pairing with and without a database.
PhotoCleanerTests/​ImportTaskTests.cs Tests image-hash deduplication, trash matching, and coordinated parallel claims.
PhotoCleanerTests/​DatabaseTests.cs Tests image-hash queries and legacy read-only database behavior.
PhotoCleanerTests/​CommandLineTests.cs Tests parsing and validation of the new command-line options.
PhotoCleaner/​TrashDatabase.cs Adds image-hash storage, schema migration, indexing, lookups, and upsert behavior.
PhotoCleaner/​TrashCommand.cs Adds process-database image-hash backfilling during trash synchronization.
PhotoCleaner/​ProcessTask.cs Adds HEIF pairing, collision-safe renaming, image-hash trash matching, and even-dimension padding.
PhotoCleaner/​ProcessCommand.cs Adds image-hash compatibility warnings during processing.
PhotoCleaner/​ImportTask.cs Implements image-hash deduplication and in-run claims for matching files.
PhotoCleaner/​ImportCommand.cs Adds image-hash support checks and legacy trash database warnings for imports.
PhotoCleaner/​Database.cs Adds image-hash lookup support and read-only schema capability detection.
PhotoCleaner/​CommandLine.cs Adds and validates the --imagehash and --processdb options.
OPERATIONS.md Documents database schema upgrades and read-only database behavior.
GUIDE.md Updates operational guidance for image-hash matching, trash handling, HEIF pairing, and rename collisions.
Directory.Packages.props Updates Serilog.Extensions.Logging to version 11.0.0.
cspell.json Adds the new image-hash and process-database option terms to the spelling dictionary.
ARCHITECTURE.md Describes the new image-hash flow, database schema handling, rename rules, conversion padding, and HEIF pairing.

Review effort: Lite

Comment thread PhotoCleaner/ProcessTask.cs Resolved
@ptr727
ptr727 merged commit 6512303 into main Nov 18, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants