[PR #13839] [MERGED] Recognize file changes and remove data on change #13734

Closed
opened 2026-02-07 07:18:15 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/13839
Author: @Shadowghost
Created: 4/4/2025
Status: Merged
Merged: 5/5/2025
Merged by: @crobibero

Base: masterHead: recognize-file-changes


📝 Commits (5)

  • 78a98a7 Recognize file changes and remove data on change
  • 60d063a Add migration for internal item paths
  • a18263d Fix check calculations in migrations
  • d565b16 Cleanup MediaSegments, fix packages and add documentation to MetadataServices
  • eca4534 Fix tests

📊 Changes

57 files changed (+1914 additions, -1124 deletions)

View changed files

📝 Emby.Server.Implementations/ApplicationHost.cs (+2 -2)
📝 Emby.Server.Implementations/Collections/CollectionManager.cs (+4 -4)
Emby.Server.Implementations/Library/KeyframeManager.cs (+44 -0)
📝 Emby.Server.Implementations/Library/LibraryManager.cs (+77 -45)
📝 Emby.Server.Implementations/Library/PathManager.cs (+14 -0)
📝 Emby.Server.Implementations/Library/ResolverHelper.cs (+15 -5)
📝 Emby.Server.Implementations/Playlists/PlaylistManager.cs (+4 -2)
📝 Emby.Server.Implementations/ScheduledTasks/Tasks/MediaSegmentExtractionTask.cs (+1 -1)
📝 Jellyfin.Api/Controllers/MediaSegmentsController.cs (+1 -1)
📝 Jellyfin.Server.Implementations/Item/KeyframeRepository.cs (+8 -0)
📝 Jellyfin.Server.Implementations/MediaSegments/MediaSegmentManager.cs (+8 -1)
📝 Jellyfin.Server/Migrations/Routines/MigrateKeyframeData.cs (+5 -0)
📝 Jellyfin.Server/Migrations/Routines/MoveExtractedFiles.cs (+5 -0)
Jellyfin.Server/Migrations/Routines/RefreshInternalDateModified.cs (+131 -0)
📝 MediaBrowser.Controller/Entities/BaseItem.cs (+36 -4)
📝 MediaBrowser.Controller/IO/IPathManager.cs (+9 -1)
MediaBrowser.Controller/Library/IKeyframeManager.cs (+37 -0)
📝 MediaBrowser.Controller/Library/ILibraryManager.cs (+4 -4)
📝 MediaBrowser.Controller/MediaSegments/IMediaSegmentManager.cs (+8 -1)
📝 MediaBrowser.Controller/MediaSegments/IMediaSegmentProvider.cs (+2 -4)

...and 37 more files

📄 Description

Up until now you could replace a file with a file named the same and Jellyfin would only refresh it under certain circumstances without pruning already extracted data. But this file could (and likey does) have different subtitles and attachments and potentially even has a different resolution or runtime, so trickplay files might be off too.

Changes

  • Properly update and check DateModified
  • Add migration to set BaseItem.DateModified and check BaseItem.Size and fix them if necessary
  • Add validation logic to MetadataManager.BeforeSave to check for filesystem differences:
    • Always update DateModified, Size and potentially DateCreated (depending on server setting) on scan
    • Remove extracted trickplay images, subtitles and attachments if file changed
    • DVD and BD directories use the sizes returned by the probers while other items use the ones reported by the file system

Remarks
We use the LastWriteTime which corresponds with mtime on Linux and is reliable on Windows. Contrary to that creation time is not reliable on Windows due to filesystem tunneling ,


🔄 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/13839 **Author:** [@Shadowghost](https://github.com/Shadowghost) **Created:** 4/4/2025 **Status:** ✅ Merged **Merged:** 5/5/2025 **Merged by:** [@crobibero](https://github.com/crobibero) **Base:** `master` ← **Head:** `recognize-file-changes` --- ### 📝 Commits (5) - [`78a98a7`](https://github.com/jellyfin/jellyfin/commit/78a98a7800f1856690989fbc6266ad3d7e80d560) Recognize file changes and remove data on change - [`60d063a`](https://github.com/jellyfin/jellyfin/commit/60d063a1f126c48d464a8e0d5e4f413d4881c61b) Add migration for internal item paths - [`a18263d`](https://github.com/jellyfin/jellyfin/commit/a18263dce4eac4132120425bc6e5d53a1157199b) Fix check calculations in migrations - [`d565b16`](https://github.com/jellyfin/jellyfin/commit/d565b160604b4061881adcf56ac09ca22a8f85d5) Cleanup MediaSegments, fix packages and add documentation to MetadataServices - [`eca4534`](https://github.com/jellyfin/jellyfin/commit/eca4534d435e4fb207e4564535f2be781e768c30) Fix tests ### 📊 Changes **57 files changed** (+1914 additions, -1124 deletions) <details> <summary>View changed files</summary> 📝 `Emby.Server.Implementations/ApplicationHost.cs` (+2 -2) 📝 `Emby.Server.Implementations/Collections/CollectionManager.cs` (+4 -4) ➕ `Emby.Server.Implementations/Library/KeyframeManager.cs` (+44 -0) 📝 `Emby.Server.Implementations/Library/LibraryManager.cs` (+77 -45) 📝 `Emby.Server.Implementations/Library/PathManager.cs` (+14 -0) 📝 `Emby.Server.Implementations/Library/ResolverHelper.cs` (+15 -5) 📝 `Emby.Server.Implementations/Playlists/PlaylistManager.cs` (+4 -2) 📝 `Emby.Server.Implementations/ScheduledTasks/Tasks/MediaSegmentExtractionTask.cs` (+1 -1) 📝 `Jellyfin.Api/Controllers/MediaSegmentsController.cs` (+1 -1) 📝 `Jellyfin.Server.Implementations/Item/KeyframeRepository.cs` (+8 -0) 📝 `Jellyfin.Server.Implementations/MediaSegments/MediaSegmentManager.cs` (+8 -1) 📝 `Jellyfin.Server/Migrations/Routines/MigrateKeyframeData.cs` (+5 -0) 📝 `Jellyfin.Server/Migrations/Routines/MoveExtractedFiles.cs` (+5 -0) ➕ `Jellyfin.Server/Migrations/Routines/RefreshInternalDateModified.cs` (+131 -0) 📝 `MediaBrowser.Controller/Entities/BaseItem.cs` (+36 -4) 📝 `MediaBrowser.Controller/IO/IPathManager.cs` (+9 -1) ➕ `MediaBrowser.Controller/Library/IKeyframeManager.cs` (+37 -0) 📝 `MediaBrowser.Controller/Library/ILibraryManager.cs` (+4 -4) 📝 `MediaBrowser.Controller/MediaSegments/IMediaSegmentManager.cs` (+8 -1) 📝 `MediaBrowser.Controller/MediaSegments/IMediaSegmentProvider.cs` (+2 -4) _...and 37 more files_ </details> ### 📄 Description Up until now you could replace a file with a file named the same and Jellyfin would only refresh it under certain circumstances without pruning already extracted data. But this file could (and likey does) have different subtitles and attachments and potentially even has a different resolution or runtime, so trickplay files might be off too. **Changes** * Properly update and check `DateModified` * Add migration to set `BaseItem.DateModified` and check `BaseItem.Size` and fix them if necessary * Add validation logic to `MetadataManager.BeforeSave` to check for filesystem differences: * Always update `DateModified`, `Size` and potentially `DateCreated` (depending on server setting) on scan * Remove extracted trickplay images, subtitles and attachments if file changed * DVD and BD directories use the sizes returned by the probers while other items use the ones reported by the file system **Remarks** We use the `LastWriteTime` which corresponds with `mtime` on Linux and is reliable on Windows. Contrary to that creation time [is not reliable on Windows due to filesystem tunneling ](https://superuser.com/questions/1804174/when-the-storage-device-is-formatted-with-ntfs-the-file-tunneling-system-does-n), --- <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-07 07:18:15 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#13734