Esempio n. 1
0
        CompareIntegrityAsync(IProgress <IntegrityCheckProgress> progress, DirectoryInfo gamePath)
        {
            IntegrityCheckResult remoteIntegrity;

            try
            {
                remoteIntegrity = DownloadIntegrityCheckForVersion(XivGame.GetLocalGameVer(gamePath));
            }
            catch (WebException)
            {
                return(CompareResult.NoServer, null, null);
            }

            var localIntegrity = await RunIntegrityCheckAsync(gamePath, progress);

            var report = "";

            foreach (var hashEntry in remoteIntegrity.Hashes)
            {
                if (localIntegrity.Hashes.Any(h => h.Key == hashEntry.Key))
                {
                    if (localIntegrity.Hashes.First(h => h.Key == hashEntry.Key).Value != hashEntry.Value)
                    {
                        report += $"Mismatch: {hashEntry.Key}\n";
                    }
                }
                else
                {
                    Debug.WriteLine("File not found in local integrity: " + hashEntry.Key);
                }
            }

            return(string.IsNullOrEmpty(report) ? CompareResult.Valid : CompareResult.Invalid, report,
                   remoteIntegrity);
        }
Esempio n. 2
0
        public static async Task <IntegrityCheckResult> RunIntegrityCheckAsync(DirectoryInfo gamePath,
                                                                               IProgress <IntegrityCheckProgress> progress)
        {
            var hashes = new Dictionary <string, string>();

            using (var sha1 = new SHA1Managed())
            {
                CheckDirectory(gamePath, sha1, gamePath.FullName, ref hashes, progress);
            }

            return(new IntegrityCheckResult
            {
                GameVersion = XivGame.GetLocalGameVer(gamePath),
                Hashes = hashes
            });
        }