You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/src/NzbDrone.Core/MediaCover/CoverAlreadyExistsSpecifica...

33 lines
912 B

using System;
using NzbDrone.Common.Disk;
namespace NzbDrone.Core.MediaCover
{
public interface ICoverExistsSpecification
{
bool AlreadyExists(DateTime serverModifiedDate, string localPath);
}
public class CoverAlreadyExistsSpecification : ICoverExistsSpecification
{
private readonly IDiskProvider _diskProvider;
public CoverAlreadyExistsSpecification(IDiskProvider diskProvider)
{
_diskProvider = diskProvider;
}
public bool AlreadyExists(DateTime lastModifiedDateServer, string localPath)
{
if (!_diskProvider.FileExists(localPath))
{
return false;
}
DateTime? lastModifiedLocal = _diskProvider.FileGetLastWrite(localPath);
return lastModifiedLocal.Value.ToUniversalTime() == lastModifiedDateServer.ToUniversalTime();
}
}
}