예제 #1
0
        public static async Task <(CompareResult compareResult, string report, IntegrityCheckResult remoteIntegrity)> CompareIntegrityAsync(IProgress <IntegrityCheckProgress> progress)
        {
            IntegrityCheckResult remoteIntegrity;

            try
            {
                remoteIntegrity = DownloadIntegrityCheckForVersion(XIVGame.GetLocalGamever());
            }
            catch (WebException)
            {
                return(CompareResult.NoServer, null, null);
            }

            var localIntegrity = await RunIntegrityCheckAsync(new DirectoryInfo(Settings.GetGamePath()), 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);
        }
예제 #2
0
        private static async Task <IntegrityCheckResult> RunIntegrityCheckAsync(DirectoryInfo gameDirectory, IProgress <IntegrityCheckProgress> progress)
        {
            var hashes = new Dictionary <string, string>();

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

            return(new IntegrityCheckResult
            {
                GameVersion = XIVGame.GetLocalGamever(),
                Hashes = hashes
            });
        }