mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-31 14:33:54 -04:00
fix file modification date comparisons (#14503)
This commit is contained in:
parent
536437bbe3
commit
6f49782b7b
@ -49,7 +49,7 @@ public class PhotoProvider : ICustomMetadataProvider<Photo>, IForcedProvider, IH
|
||||
if (item.IsFileProtocol)
|
||||
{
|
||||
var file = directoryService.GetFile(item.Path);
|
||||
return file is not null && file.LastWriteTimeUtc != item.DateModified;
|
||||
return file is not null && item.HasChanged(file.LastWriteTimeUtc);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -1954,7 +1954,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
try
|
||||
{
|
||||
return _fileSystem.GetLastWriteTimeUtc(image.Path) != image.DateModified;
|
||||
return image.DateModified.Subtract(_fileSystem.GetLastWriteTimeUtc(image.Path)).Duration().TotalSeconds > 1;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -1430,9 +1430,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
var info = FileSystem.GetFileSystemInfo(Path);
|
||||
|
||||
return info.Exists
|
||||
? info.LastWriteTimeUtc != DateModified
|
||||
: false;
|
||||
return info.Exists && this.HasChanged(info.LastWriteTimeUtc);
|
||||
}
|
||||
|
||||
public virtual List<string> GetUserDataKeys()
|
||||
|
@ -114,5 +114,19 @@ namespace MediaBrowser.Controller.Entities
|
||||
source.DeepCopy(dest);
|
||||
return dest;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the item has changed.
|
||||
/// </summary>
|
||||
/// <param name="source">The source object.</param>
|
||||
/// <param name="asOf">The timestamp to detect changes as of.</param>
|
||||
/// <typeparam name="T">Source type.</typeparam>
|
||||
/// <returns>Whether the item has changed.</returns>
|
||||
public static bool HasChanged<T>(this T source, DateTime asOf)
|
||||
where T : BaseItem
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(source);
|
||||
return source.DateModified.Subtract(asOf).Duration().TotalSeconds > 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user