Exemplo n.º 1
0
        public override Task VerifyHashes()
        {
            return(Task.Run(async() =>
            {
                var patch = await FetchPatch();
                var fileList = await FetchPatchManifest(patch.PatchId);

                fileList.Files.GroupBy(f => f.HashGroup)
                .ForEach(group =>
                {
                    var hm = new HashManager(group.Key);

                    hm.Load();

                    foreach (var file in group)
                    {
                        foreach (var listener in VerificationProgressUpdated)
                        {
                            listener.Invoke(file.FullFile, file.WebPath, (uint)group.ToList().IndexOf(file) + 1, (uint)group.Count());
                        }

                        try
                        {
                            hm.Check(file.FullFile, DataUtil.ComputeHash(file.FullFile));
                        }
                        catch (IntegrityException e)
                        {
                            foreach (var listener in VerificationFailed)
                            {
                                listener.Invoke(e.FilePath, e.ExpectedHash, e.ActualHash);
                            }
                        }
                    }
                });
            }));
        }