Пример #1
0
        /// <summary>
        /// Download and open an remote TACT container
        /// <para>Note: This will download the entire CDN so will take a while</para>
        /// </summary>
        /// <param name="url"></param>
        /// <param name="tprDirectory"></param>
        /// <param name="product"></param>
        /// <param name="locale"></param>
        public void DownloadRemote(string tprDirectory, string product, Locale locale, bool systemFileOnly = false)
        {
            ManifestContainer = new Configs.ManifestContainer(product, locale);
            ManifestContainer.DownloadRemote(BaseDirectory);

            ConfigContainer = new Configs.ConfigContainer();
            ConfigContainer.DownloadRemote(tprDirectory, ManifestContainer);

            var cdnClient      = new CDNClient(ManifestContainer);
            var queuedDownload = new QueuedDownloader(tprDirectory, cdnClient);

            if (ConfigContainer.EncodingEKey.Value != null)
            {
                // Download encoding file
                var encodingEKey = DownloadSystemFile(ConfigContainer.EncodingEKey, cdnClient, tprDirectory);
                if (encodingEKey.Value != null)
                {
                    EncodingFile = new Encoding.EncodingFile(tprDirectory, encodingEKey, true);
                }

                // Download PatchFile
                DownloadSystemFile(ConfigContainer.PatchEKey, cdnClient, tprDirectory, "patch");

                // Download RootFile
                if (EncodingFile.TryGetCKeyEntry(ConfigContainer.RootCKey, out var ekeyEntry))
                {
                    ekeyEntry.EKeys.ForEach(x => queuedDownload.Enqueue(x.Value.ToString()));
                }

                // Download InstallFile
                if (EncodingFile.TryGetCKeyEntry(ConfigContainer.InstallCKey, out ekeyEntry))
                {
                    ekeyEntry.EKeys.ForEach(x => queuedDownload.Enqueue(x.Value.ToString()));
                }

                // Download DownloadFile
                if (EncodingFile.TryGetCKeyEntry(ConfigContainer.DownloadCKey, out ekeyEntry))
                {
                    ekeyEntry.EKeys.ForEach(x => queuedDownload.Enqueue(x.Value.ToString()));
                }

                // Download DownloadSizeFile
                if (EncodingFile.TryGetCKeyEntry(ConfigContainer.DownloadSizeCKey, out ekeyEntry))
                {
                    ekeyEntry.EKeys.ForEach(x => queuedDownload.Enqueue(x.Value.ToString()));
                }

                queuedDownload.Download("data");
            }

            // Download Indices and archives
            if (!systemFileOnly)
            {
                IndexContainer = new Indices.IndexContainer();
                IndexContainer.DownloadRemote(tprDirectory, ConfigContainer, ManifestContainer);
            }

            Open(tprDirectory);
        }
Пример #2
0
        /// <summary>
        /// Downloads all Index and Archive files from a remote CDN
        /// </summary>
        /// <param name="directory"></param>
        /// <param name="configContainer"></param>
        public void DownloadRemote(string directory, Configs.ConfigContainer configContainer, Configs.ManifestContainer manifestContainer)
        {
            _client = new CDNClient(manifestContainer);

            var queuedDownloader = new QueuedDownloader(directory, _client);

            // download data archives
            var archives = configContainer.CDNConfig.GetValues("archives");

            if (archives != null && archives.Count > 0)
            {
                queuedDownloader.Enqueue(archives);
                queuedDownloader.Enqueue(archives, (x) => x + ".index");
                queuedDownloader.Download("data");
            }

            // download patch archives
            var patcharchives = configContainer.CDNConfig.GetValues("patch-archives");

            if (patcharchives != null && patcharchives.Count > 0)
            {
                queuedDownloader.Enqueue(patcharchives);
                queuedDownloader.Enqueue(patcharchives, (x) => x + ".index");
                queuedDownloader.Download("patch");
            }

            // download loose file index
            var fileIndex = configContainer.CDNConfig.GetValue("file-index");

            if (fileIndex != null)
            {
                string url  = Helpers.GetCDNUrl(fileIndex, "data");
                string path = Helpers.GetCDNPath(fileIndex, "data", directory, true);
                _client.DownloadFile(url, path).Wait();

                // download loose files
                var index = new IndexFile(path);
                queuedDownloader.Enqueue(index.Entries, (x) => x.Key.ToString());
                queuedDownloader.Download("data");
            }

            // download loose patch file index
            var patchIndex = configContainer.CDNConfig.GetValue("patch-file-index");

            if (patchIndex != null)
            {
                string url  = Helpers.GetCDNUrl(patchIndex, "patch");
                string path = Helpers.GetCDNPath(patchIndex, "patch", directory, true);
                _client.DownloadFile(url, path).Wait();

                // download loose patches
                var index = new IndexFile(path);
                queuedDownloader.Enqueue(index.Entries, (x) => x.Key.ToString());
                queuedDownloader.Download("patch");
            }

            Open(directory);
        }
Пример #3
0
        /// <summary>
        /// Download and open an remote TACT container
        /// <para>Note: This will download the entire CDN so will take a while</para>
        /// </summary>
        /// <param name="url"></param>
        /// <param name="directory"></param>
        /// <param name="product"></param>
        /// <param name="locale"></param>
        public void DownloadRemote(string directory, string product, Locale locale)
        {
            ConfigContainer = new Configs.ConfigContainer(product, locale);
            ConfigContainer.DownloadRemote(directory);

            var cdnClient      = new CDNClient(ConfigContainer);
            var queuedDownload = new QueuedDownloader(directory, cdnClient);

            if (ConfigContainer.EncodingEKey.Value != null)
            {
                // Download encoding file
                var encodingEKey = DownloadSystemFile(ConfigContainer.EncodingEKey, cdnClient, directory);
                if (encodingEKey.Value != null)
                {
                    EncodingFile = new Encoding.EncodingFile(BaseDirectory, encodingEKey, true);
                }

                // Download PatchFile
                DownloadSystemFile(ConfigContainer.PatchEKey, cdnClient, directory, "patch");

                // Download RootFile
                if (EncodingFile.TryGetCKeyEntry(ConfigContainer.RootCKey, out var ekeyEntry))
                {
                    queuedDownload.Enqueue(ekeyEntry.EKey.ToString());
                }

                // Download InstallFile
                if (EncodingFile.TryGetCKeyEntry(ConfigContainer.InstallCKey, out ekeyEntry))
                {
                    queuedDownload.Enqueue(ekeyEntry.EKey.ToString());
                }

                // Download DownloadFile
                if (EncodingFile.TryGetCKeyEntry(ConfigContainer.DownloadCKey, out ekeyEntry))
                {
                    queuedDownload.Enqueue(ekeyEntry.EKey.ToString());
                }

                // Download DownloadSizeFile
                if (EncodingFile.TryGetCKeyEntry(ConfigContainer.DownloadSizeCKey, out ekeyEntry))
                {
                    queuedDownload.Enqueue(ekeyEntry.EKey.ToString());
                }

                queuedDownload.Download("data");
            }

            // Download Indices and archives
            IndexContainer = new Indices.IndexContainer();
            IndexContainer.DownloadRemote(directory, ConfigContainer);

            Open(directory, product, locale);
        }