[PR #16380] [MERGED] fix(server): skip stacked assets in duplicate detection #14857

Closed
opened 2026-02-05 15:39:04 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/immich-app/immich/pull/16380
Author: @mertalev
Created: 2/27/2025
Status: Merged
Merged: 2/27/2025
Merged by: @alextran1502

Base: mainHead: fix/server-dupe-stacked-assets


📝 Commits (3)

  • 5744eb9 skip stacked assets in duplicate detection
  • a0ea7e8 update sql
  • 50e133f handle stacking after duplicate detection runs

📊 Changes

8 files changed (+34 additions, -0 deletions)

View changed files

server/src/migrations/1740654480319-UnsetStackedAssetsFromDuplicateStatus.ts (+14 -0)
📝 server/src/queries/asset.repository.sql (+1 -0)
📝 server/src/queries/search.repository.sql (+1 -0)
📝 server/src/repositories/asset.repository.ts (+1 -0)
📝 server/src/repositories/search.repository.ts (+1 -0)
📝 server/src/services/duplicate.service.spec.ts (+10 -0)
📝 server/src/services/duplicate.service.ts (+5 -0)
📝 server/test/fixtures/asset.stub.ts (+1 -0)

📄 Description

Description

After the Kysely migration, assets were no longer stacked in the getDuplicates response, leading to errors in some cases when using the deduplication utility.

However, even before this, stacks were not handled by duplicate detection in the server or by the deduplication logic in the client:

  • Users who perform the "stack" action on a set of duplicates would see those assets once again marked as duplicates of each other after running duplicate detection
  • A stack where the primary asset was not marked duplicate but some of its members were would not show up in the utility
  • A duplicate group where all assets were part of the same stack would show up as one asset
  • Deduplicating only trashed the primary asset and not others (which, combined with the above, are the likely reasons behind straggling "1 asset" duplicate groups for so many people)
  • I'm not sure how the utility behaves when stacking already stacked assets

Pending more robust stack handling in this area, this PR skips assets part of a stack to align with the implementation assumptions.

Fixes #15735
Fixes #15868
Fixes #16359


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/immich-app/immich/pull/16380 **Author:** [@mertalev](https://github.com/mertalev) **Created:** 2/27/2025 **Status:** ✅ Merged **Merged:** 2/27/2025 **Merged by:** [@alextran1502](https://github.com/alextran1502) **Base:** `main` ← **Head:** `fix/server-dupe-stacked-assets` --- ### 📝 Commits (3) - [`5744eb9`](https://github.com/immich-app/immich/commit/5744eb9c12e854272c28e7a2f8496e3117e2d110) skip stacked assets in duplicate detection - [`a0ea7e8`](https://github.com/immich-app/immich/commit/a0ea7e8aecc2668734fdc92fc5fed796f0f11aee) update sql - [`50e133f`](https://github.com/immich-app/immich/commit/50e133f2234358472a4ddec2cf42b7f5858de04a) handle stacking after duplicate detection runs ### 📊 Changes **8 files changed** (+34 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `server/src/migrations/1740654480319-UnsetStackedAssetsFromDuplicateStatus.ts` (+14 -0) 📝 `server/src/queries/asset.repository.sql` (+1 -0) 📝 `server/src/queries/search.repository.sql` (+1 -0) 📝 `server/src/repositories/asset.repository.ts` (+1 -0) 📝 `server/src/repositories/search.repository.ts` (+1 -0) 📝 `server/src/services/duplicate.service.spec.ts` (+10 -0) 📝 `server/src/services/duplicate.service.ts` (+5 -0) 📝 `server/test/fixtures/asset.stub.ts` (+1 -0) </details> ### 📄 Description ## Description After the Kysely migration, assets were no longer stacked in the `getDuplicates` response, leading to errors in some cases when using the deduplication utility. However, even before this, stacks were not handled by duplicate detection in the server or by the deduplication logic in the client: * Users who perform the "stack" action on a set of duplicates would see those assets once again marked as duplicates of each other after running duplicate detection * A stack where the primary asset was not marked duplicate but some of its members were would not show up in the utility * A duplicate group where all assets were part of the same stack would show up as one asset * Deduplicating only trashed the primary asset and not others (which, combined with the above, are the likely reasons behind straggling "1 asset" duplicate groups for so many people) * I'm not sure how the utility behaves when stacking already stacked assets Pending more robust stack handling in this area, this PR skips assets part of a stack to align with the implementation assumptions. Fixes #15735 Fixes #15868 Fixes #16359 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 15:39:04 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#14857