Esempio n. 1
0
        private async Task DownloadPatchAsync(PatchListEntry patch, string uniqueId, IProgress <PatchDownloadProgress> progress)
        {
            using (var client = new WebClient())
            {
                client.Headers.Add("user-agent", "FFXIV PATCH CLIENT");
                client.Headers.Add("X-Patch-Unique-Id", uniqueId);

                var res = client.UploadString(
                    "http://patch-gamever.ffxiv.com/gen_token", patch.Url);

                client.DownloadProgressChanged += delegate(object sender, DownloadProgressChangedEventArgs args)
                {
                    Log.Verbose($"Downloading patch: {(int)Math.Round((double)(100 * args.BytesReceived) / patch.Length)}% ({args.BytesReceived} / {patch.Length}) - {patch.Url}");

                    progress.Report(new PatchDownloadProgress {
                        Name         = patch.VersionId,
                        CurrentBytes = args.BytesReceived,
                        Length       = patch.Length
                    });
                };

                await client.DownloadFileTaskAsync(res, Path.Combine(_patchFolder, patch.VersionId + ".patch"));

                Log.Verbose("Patch at {0} downloaded completely", patch.Url);
            }
        }
Esempio n. 2
0
        private FileInfo GetPatchFile(PatchListEntry patch)
        {
            var file = new FileInfo(Path.Combine(_patchStore.FullName, patch.GetFilePath()));

            file.Directory.Create();

            return(file);
        }
        private FileInfo GetPatchFile(PatchListEntry patch)
        {
            var file = new FileInfo(Path.Combine(_patchStore.FullName, patch.Url.Substring("http://patch-dl.ffxiv.com/".Length)));

            file.Directory.Create();

            return(file);
        }
Esempio n. 4
0
        private static HashCheckResult CheckPatchValidity(PatchListEntry patchListEntry, FileInfo path)
        {
            if (patchListEntry.HashType != "sha1")
            {
                Log.Error("??? Unknown HashType: {0} for {1}", patchListEntry.HashType, patchListEntry.Url);
                return(HashCheckResult.Pass);
            }

            var stream = path.OpenRead();

            if (stream.Length != patchListEntry.Length)
            {
                return(HashCheckResult.BadLength);
            }

            var parts = (int)Math.Round((double)patchListEntry.Length / patchListEntry.HashBlockSize);
            var block = new byte[patchListEntry.HashBlockSize];

            for (var i = 0; i < parts; i++)
            {
                var read = stream.Read(block, 0, (int)patchListEntry.HashBlockSize);

                if (read < patchListEntry.HashBlockSize)
                {
                    var trimmedBlock = new byte[read];
                    Array.Copy(block, 0, trimmedBlock, 0, read);
                    block = trimmedBlock;
                }

                using var sha1 = new SHA1Managed();

                var hash = sha1.ComputeHash(block);
                var sb   = new StringBuilder(hash.Length * 2);

                foreach (var b in hash)
                {
                    sb.Append(b.ToString("x2"));
                }

                if (sb.ToString() == patchListEntry.Hashes[i])
                {
                    continue;
                }

                stream.Close();
                return(HashCheckResult.BadHash);
            }

            stream.Close();
            return(HashCheckResult.Pass);
        }
 public void StartInstall(DirectoryInfo gameDirectory, FileInfo file, PatchListEntry patch, Repository repo)
 {
     State = InstallerState.Busy;
     SendIpcMessage(new PatcherIpcEnvelope
     {
         OpCode = PatcherIpcOpCode.StartInstall,
         Data   = new PatcherIpcStartInstall
         {
             GameDirectory = gameDirectory,
             PatchFile     = file,
             Repo          = repo,
             VersionId     = patch.VersionId
         }
     });
 }
Esempio n. 6
0
 public void StartInstall(DirectoryInfo gameDirectory, FileInfo file, PatchListEntry patch, Repository repo)
 {
     State = InstallerState.Busy;
     SendIpcMessage(new PatcherIpcEnvelope
     {
         OpCode = PatcherIpcOpCode.StartInstall,
         Data   = new PatcherIpcStartInstall
         {
             GameDirectory = gameDirectory,
             PatchFile     = file,
             Repo          = repo,
             VersionId     = patch.VersionId,
             KeepPatch     = App.Settings.KeepPatches.GetValueOrDefault(false)
         }
     });
 }
        public bool IsApplicable(PatchListEntry patch)
        {
            try
            {
                using var client = new WebClient();

                _torrentBytes = client.DownloadData("http://goaaats.github.io/patchtorrent/" + patch.GetUrlPath() + ".torrent");
            }
            catch (Exception ex)
            {
                Log.Error(ex, $"[TORRENT] Could not get torrent for patch: {patch.GetUrlPath()}");
                return(false);
            }

            return(true);
        }
Esempio n. 8
0
        private Repository GetRepoForPatch(PatchListEntry patch)
        {
            if (patch.Url.Contains("boot"))
            {
                return(Repository.Boot);
            }

            if (patch.Url.Contains("ex1"))
            {
                return(Repository.Ex1);
            }

            if (patch.Url.Contains("ex2"))
            {
                return(Repository.Ex2);
            }

            if (patch.Url.Contains("ex3"))
            {
                return(Repository.Ex3);
            }

            return(Repository.Ffxiv);
        }