Readarr/src/NzbDrone.Core/Update/UpdateVerification.cs
Taloth Saldono 35ab3a28fd New: MediaCover api now includes several resized variants to save bandwidth for mobile apps.
banner-35.jpg (height)
banner-70.jpg
fanart-180.jpg (height)
fanart-360.jpg
poster-170.jpg (width)
poster-340.jpg
2015-01-29 19:27:09 +01:00

30 lines
806 B
C#

using System;
using NzbDrone.Common.Disk;
namespace NzbDrone.Core.Update
{
public interface IVerifyUpdates
{
Boolean Verify(UpdatePackage updatePackage, String packagePath);
}
public class UpdateVerification : IVerifyUpdates
{
private readonly IDiskProvider _diskProvider;
public UpdateVerification(IDiskProvider diskProvider)
{
_diskProvider = diskProvider;
}
public Boolean Verify(UpdatePackage updatePackage, String packagePath)
{
using (var fileStream = _diskProvider.OpenReadStream(packagePath))
{
var hash = fileStream.SHA256Hash();
return hash.Equals(updatePackage.Hash, StringComparison.CurrentCultureIgnoreCase);
}
}
}
}