[PR #11816] Add file hash to images and remove duplicates after scan #12832

Open
opened 2025-12-22 09:31:13 +01:00 by backuprepo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/11816
Author: @Shadowghost
Created: 5/24/2024
Status: 🔄 Open

Base: masterHead: fix-duplicate-backdrops


📝 Commits (1)

  • 208811f Add file hash to images and remove duplicates after scan

📊 Changes

15 files changed (+2057 additions, -191 deletions)

View changed files

📝 Directory.Packages.props (+1 -0)
📝 Emby.Server.Implementations/Library/LibraryManager.cs (+50 -2)
📝 Jellyfin.Server.Implementations/Item/BaseItemRepository.cs (+1 -0)
📝 Jellyfin.Server.Implementations/Item/ChapterRepository.cs (+12 -23)
📝 MediaBrowser.Controller/Drawing/IImageProcessor.cs (+11 -4)
📝 MediaBrowser.Controller/Entities/BaseItem.cs (+1 -0)
📝 MediaBrowser.Controller/Entities/ItemImageInfo.cs (+6 -0)
📝 src/Jellyfin.Database/Jellyfin.Database.Implementations/Entities/BaseItemImageInfo.cs (+7 -3)
src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/Migrations/20250326065939_AddImageFileHash.Designer.cs (+1655 -0)
src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/Migrations/20250326065939_AddImageFileHash.cs (+28 -0)
📝 src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/Migrations/JellyfinDbModelSnapshot.cs (+139 -78)
📝 src/Jellyfin.Drawing/ImageProcessor.cs (+60 -13)
📝 src/Jellyfin.Drawing/Jellyfin.Drawing.csproj (+1 -0)
📝 tests/Jellyfin.Server.Implementations.Tests/Data/SqliteItemRepositoryTests.cs (+85 -67)
📝 tests/Jellyfin.Server.Implementations.Tests/EfMigrations/EfMigrationTests.cs (+0 -1)

📄 Description

We are allowing multiple backdrops but never clean up duplicates after scan - these might appear if we have an image in the media folder and download the image from the NFO but they are the same.

Changes

  • Use XxHash3 to calcultate image file hash on scan if we haven't already
  • Save hash to the database
  • Remove duplicate backdrops on scan based on hash, preferring external images over ones in the JF metadata folder

ToDo

  • Potentially write a migration, though it is fixed by a simple rescan

Issues
Fixes #9456
Replaces #9551


🔄 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/jellyfin/jellyfin/pull/11816 **Author:** [@Shadowghost](https://github.com/Shadowghost) **Created:** 5/24/2024 **Status:** 🔄 Open **Base:** `master` ← **Head:** `fix-duplicate-backdrops` --- ### 📝 Commits (1) - [`208811f`](https://github.com/jellyfin/jellyfin/commit/208811fb7fc3a64e7cf35dbcba20bc1a9c173ef7) Add file hash to images and remove duplicates after scan ### 📊 Changes **15 files changed** (+2057 additions, -191 deletions) <details> <summary>View changed files</summary> 📝 `Directory.Packages.props` (+1 -0) 📝 `Emby.Server.Implementations/Library/LibraryManager.cs` (+50 -2) 📝 `Jellyfin.Server.Implementations/Item/BaseItemRepository.cs` (+1 -0) 📝 `Jellyfin.Server.Implementations/Item/ChapterRepository.cs` (+12 -23) 📝 `MediaBrowser.Controller/Drawing/IImageProcessor.cs` (+11 -4) 📝 `MediaBrowser.Controller/Entities/BaseItem.cs` (+1 -0) 📝 `MediaBrowser.Controller/Entities/ItemImageInfo.cs` (+6 -0) 📝 `src/Jellyfin.Database/Jellyfin.Database.Implementations/Entities/BaseItemImageInfo.cs` (+7 -3) ➕ `src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/Migrations/20250326065939_AddImageFileHash.Designer.cs` (+1655 -0) ➕ `src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/Migrations/20250326065939_AddImageFileHash.cs` (+28 -0) 📝 `src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/Migrations/JellyfinDbModelSnapshot.cs` (+139 -78) 📝 `src/Jellyfin.Drawing/ImageProcessor.cs` (+60 -13) 📝 `src/Jellyfin.Drawing/Jellyfin.Drawing.csproj` (+1 -0) 📝 `tests/Jellyfin.Server.Implementations.Tests/Data/SqliteItemRepositoryTests.cs` (+85 -67) 📝 `tests/Jellyfin.Server.Implementations.Tests/EfMigrations/EfMigrationTests.cs` (+0 -1) </details> ### 📄 Description We are allowing multiple backdrops but never clean up duplicates after scan - these might appear if we have an image in the media folder and download the image from the NFO but they are the same. **Changes** * Use `XxHash3` to calcultate image file hash on scan if we haven't already * Save hash to the database * Remove duplicate backdrops on scan based on hash, preferring external images over ones in the JF metadata folder **ToDo** * Potentially write a migration, though it is fixed by a simple rescan **Issues** Fixes #9456 Replaces #9551 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
backuprepo added the
pull-request
label 2025-12-22 09:31:13 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: starred/jellyfin#12832
No description provided.