public PatchHistory(PatchHistory patchHistory, FileList fileList, string patchVersionName) { ID = Guid.NewGuid(); FileList = fileList; PatchVersionName = patchVersionName; CreationDate = DateTime.UtcNow; if (patchHistory != null) { PatchHistoryList = patchHistory.PatchHistoryList.ToList(); PatchHistoryList.Add(patchHistory); patchHistory.FileList = null; patchHistory.PatchHistoryList = null; } else { PatchHistoryList = new List <PatchHistory>(); } }
public static bool VerifyMD5Checksum(string basePath, PatchHistory patchHistory) { Dictionary <string, byte[]> checksum = patchHistory.FileList.Checksum; List <string> fileList = patchHistory.FileList.ToBeDownloaded; bool result = true; foreach (string file in fileList) { using (var md5 = MD5.Create()) { using (var stream = new StreamReader($@"{basePath}\{file}")) { if (!(result &= checksum[file].SequenceEqual(md5.ComputeHash(stream.BaseStream)))) { return(false); } } } } return(true); }