check hashes in mirror downloaders

This commit is contained in:
IsWaffle 2023-09-21 18:51:20 -04:00
parent b6f883ec38
commit 174e21d03f
2 changed files with 12 additions and 2 deletions

View File

@ -10,6 +10,11 @@ public class HttpMirrorDownloader : MirrorDownloaderBase
public override async Task<FileInfo?> Download(IProgress<double> progress) public override async Task<FileInfo?> Download(IProgress<double> progress)
{ {
return await DownloadCacheHelper.DownloadFileAsync("patcher.zip", MirrorInfo.Link, progress); var file = await DownloadCacheHelper.DownloadFileAsync("patcher.zip", MirrorInfo.Link, progress);
if (file == null)
return null;
return FileHashHelper.CheckHash(file, MirrorInfo.Hash) ? file : null;
} }
} }

View File

@ -22,7 +22,12 @@ public class MegaMirrorDownloader : MirrorDownloaderBase
{ {
using var megaDownloadStream = await megaClient.DownloadAsync(new Uri(MirrorInfo.Link), progress); using var megaDownloadStream = await megaClient.DownloadAsync(new Uri(MirrorInfo.Link), progress);
return await DownloadCacheHelper.DownloadFileAsync("patcher.zip", megaDownloadStream); var file = await DownloadCacheHelper.DownloadFileAsync("patcher.zip", megaDownloadStream);
if (file == null)
return null;
return FileHashHelper.CheckHash(file, MirrorInfo.Hash) ? file : null;
} }
catch catch
{ {