Repository navigation
Add Catalog Columns and DB-Backed Live Photo Pairing - #275
Conversation
Add content_identifier, image_hash and metadata_read columns to the files table, upgraded in place on open. The catalog fills them in one exiftool run that also returns the image data hash, which needs ExifTool 12.63 or newer. Make process catalog every file first, then run the per-file pipeline. With --db a Live Photo video finds its still by ContentIdentifier among catalogued image rows, whatever the name or folder. Without --db the same-folder name lookup is unchanged. Tracks #274.
A video never pairs with a catalog row holding its own content, which a stale name under an image extension could otherwise produce. A file that exiftool reports an error for stays unread instead of being stored as having no tags. A read-only database in the old shape still answers hash lookups, and the unused partial-schema guard is removed. Tracks #274.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
There was a problem hiding this comment.
🟡 Changes recommended
Active moderate and critical findings remain around stale-row backfilling, nondeterministic Live Photo pair processing, redundant metadata reads, and incomplete phase coverage.
3 open issues
What changed in this PR
This PR adds catalog metadata and database-backed Live Photo pairing across different names and folders, and introduces a two-phase process workflow that catalogs files before processing them.
Changes:
- Adds
content_identifier,image_hash, andmetadata_readcolumns with in-place migration and backfill support. - Extends indexing, importing, and processing with ExifTool metadata and image-hash reads.
- Adds catalog-based pairing, documentation updates, and tests for upgrades, backfill, and pairing behavior.
| File | Description |
|---|---|
| README.md | Documents catalog columns, ExifTool requirements, and database-backed Live Photo pairing behavior. |
| PhotoCleanerTests/LivePhotoCatalogTests.cs | Adds tests for catalog pairing, schema upgrades, metadata backfill, image hashes, and related processing behavior. |
| PhotoCleaner/ProcessTask.cs | Uses database catalog metadata to locate Live Photo stills and exclude self-matches. |
| PhotoCleaner/ProcessCommand.cs | Adds a cataloging phase before per-file processing. |
| PhotoCleaner/MediaUtilities.cs | Adds ExifTool version checks and catalog metadata reads including image-data hashes. |
| PhotoCleaner/IndexTask.cs | Reads and persists catalog metadata during database indexing. |
| PhotoCleaner/ImportTask.cs | Reads and stores catalog metadata during database-backed imports. |
| PhotoCleaner/ExifToolJson.cs | Adds JSON deserialization for the image-data hash field. |
| PhotoCleaner/DatabaseScope.cs | Validates ExifTool image-hash support for writable database commands. |
| PhotoCleaner/Database.cs | Adds catalog columns, migrations, metadata updates, indexes, and ContentIdentifier lookup queries. |
| OPERATIONS.md | Documents the minimum ExifTool version required for catalog reads. |
| ARCHITECTURE.md | Describes catalog metadata, two-phase processing, and database-based Live Photo pairing. |
Review effort: Lite
Deleting a file trashed in Immich no longer deletes its catalog row, so a Live Photo video pairs with a trashed still whichever of the two process handles first. Add tests for the trashed-still order and for the video sorting before its still, and document the cost of the two exiftool runs per new file. Tracks #274.
Verify indexes without reading catalog metadata, so it needs no exiftool and no longer hashes image data for every already verified file. Reuse the pre-process SHA-256 for the Live pairing exclusion, drop the unused row delete, and correct the documentation of the upgrade and rehash behavior. Tracks #274.
The test starts with both files unindexed and the video listed before its still. It fails when the catalog phase is removed. Tracks #274.
Import skips a known source before reading metadata, so only index and process backfill an old row. Tracks #274.
There was a problem hiding this comment.
🟡 Changes recommended
Two critical P1 issues remain: stale image-extension rows can cause videos without stills to be deleted, and the required Keys:ContentIdentifier mapping is missing, preventing valid live-photo video pairing.
2 open issues
3 resolved since last review
Review effort: Lite
The IndexTask cache tests index dummy text files and need no metadata, so they read none. They pass on a runner with no exiftool installed. Tracks #274.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #275 +/- ##
===========================================
- Coverage 43.37% 41.25% -2.13%
===========================================
Files 28 27 -1
Lines 3896 4138 +242
Branches 306 362 +56
===========================================
+ Hits 1690 1707 +17
- Misses 2154 2361 +207
- Partials 52 70 +18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🔵 Needs a closer look
Maintainer judgment is required because the catalog lacks durable media identity, allowing stale or misnamed video rows to be mistaken for stills and potentially deleted destructively.
1 open issue
1 resolved since last review
Review effort: Lite
Move the schema and mapping tests to a class with no tool dependency so they run on a runner without exiftool. The media fixture skips instead of failing when the installed exiftool is older than the minimum. Tracks #274.
The media fixture stays unchanged, so a host with an exiftool older than the minimum fails with the version message instead of skipping tests that never read catalog metadata. Tracks #274.
|
A recorded local strict-review pass covers head |
A catalog row whose image hash equals the video's own never counts as its still, so a copy of one video under an image extension no longer deletes the video. Test stills use a different video as their media. List the new test files in the architecture notes. Tracks #274.
The stale row has no image hash, so only the SHA-256 exclusion can keep the video from pairing with itself. Correct the stale fixture comment. Tracks #274.
|
A recorded local strict-review pass covers head |



Summary
Tracks #274. The
filestable gainscontent_identifier,image_hashandmetadata_readcolumns, andprocesspairs a Live Photo video with its still through the catalog instead of a same-folder name match.metadata_readseparates "not read yet" from "read, tag absent", so old rows backfill once when the file still exists.IndexTask.IndexFileAsyncfills both columns under the existing path, size and mtime cache, using one exiftool run with-ImageDataHash -api ImageHashType=SHA256.index,importandprocesspopulate through it.verifyindexes without reading metadata, so it needs no exiftool. ExifTool 12.63 or newer is required, per the ExifTool version history, and an older version fails the run with a message.processcatalogs every file in parallel first, then runs the per-file pipeline against the warm cache. A new file costs two exiftool runs, one in each phase, because parsed metadata is not carried across phases.--db, the still is any image row with the samecontent_identifier, whatever its name or folder, including a still whose file is gone. A row holding the video's own content never counts as its still. Without--dbthe same-folder lookup is unchanged.processhandles first.exiftool cannot create the Apple MakerNotes
ContentIdentifiertag in a JPEG that has no maker note (ExifTool FAQ: MakerNotes tags can only be written if they already exist), so no real-still fixture exists. Pairing tests use a video-container file named.heic, and aProcessCommandtest proves the catalog phase runs first.Verification
dotnet build: 0 warnings, 0 errors.dotnet test: 393 total, 388 passed (289 passed and 104 skipped on a runner with no exiftool or ffmpeg, see Run the Media Tests in CI With exiftool and ffmpeg Installed #277), 0 failed, 5 skipped (Docker or Immich unavailable, unchanged).LivePhotoCatalogTests.cscover differing stems, different date folders, an id with+and U+FF0F, a still absent from disk, a trashed still processed first, no or non-matching ContentIdentifier, no---dbbehavior, in-place upgrade, backfill, metadata reading off, and image hash equality. Three tests were shown failing with their guard removed.Open review findings
image_hashorsha256equals the video's own..heifis renamed to.heiconly in the first process round, so a video judged in that round can be kept. See Pair Live Photo Videos With Stills Renamed in the Same Process Round #276.--reprocessis given.ProcessCommandtest fails without the catalog phase in three of three runs, but file enumeration order is not guaranteed, so it can pass without it.