fix file modification date comparisons (#14503)

This commit is contained in:
evan314159
2025-07-28 10:08:06 +08:00
committed by GitHub
parent 536437bbe3
commit 6f49782b7b
8 changed files with 23 additions and 13 deletions

View File

@@ -332,13 +332,11 @@ namespace MediaBrowser.Providers.Manager
if (!string.IsNullOrEmpty(itemPath))
{
var info = FileSystem.GetFileSystemInfo(itemPath);
var modificationDate = info.LastWriteTimeUtc;
var itemLastModifiedFileSystem = item.DateModified;
if (info.Exists && itemLastModifiedFileSystem != modificationDate)
if (info.Exists && item.HasChanged(info.LastWriteTimeUtc))
{
Logger.LogDebug("File modification time changed from {Then} to {Now}: {Path}", itemLastModifiedFileSystem, modificationDate, itemPath);
Logger.LogDebug("File modification time changed from {Then} to {Now}: {Path}", item.DateModified, info.LastWriteTimeUtc, itemPath);
item.DateModified = modificationDate;
item.DateModified = info.LastWriteTimeUtc;
if (ServerConfigurationManager.GetMetadataConfiguration().UseFileCreationTimeForDateAdded)
{
item.DateCreated = info.CreationTimeUtc;

View File

@@ -130,7 +130,7 @@ namespace MediaBrowser.Providers.MediaInfo
if (!string.IsNullOrWhiteSpace(path) && item.IsFileProtocol)
{
var file = directoryService.GetFile(path);
if (file is not null && file.LastWriteTimeUtc != item.DateModified && file.Length != item.Size)
if (file is not null && item.HasChanged(file.LastWriteTimeUtc) && file.Length != item.Size)
{
_logger.LogDebug("Refreshing {ItemPath} due to file system modification.", path);
return true;

View File

@@ -215,7 +215,7 @@ public class PlaylistItemsProvider : ILocalMetadataProvider<Playlist>,
if (!string.IsNullOrWhiteSpace(path) && item.IsFileProtocol)
{
var file = directoryService.GetFile(path);
if (file is not null && file.LastWriteTimeUtc != item.DateModified)
if (file is not null && item.HasChanged(file.LastWriteTimeUtc))
{
_logger.LogDebug("Refreshing {Path} due to date modified timestamp change.", path);
return true;

View File

@@ -56,7 +56,7 @@ public class TrickplayProvider : ICustomMetadataProvider<Episode>,
if (item.IsFileProtocol)
{
var file = directoryService.GetFile(item.Path);
if (file is not null && item.DateModified != file.LastWriteTimeUtc)
if (file is not null && item.HasChanged(file.LastWriteTimeUtc))
{
return true;
}