Beispiel #1
0
        public Installer(
            AppSourceConfig appSourceConfig,
            MtgjsonSourceConfig mtgjsonSourceConfig,
            CardSearcher cardSearcher,
            KeywordSearcher keywordSearcher)
        {
            _appSourceConfig     = appSourceConfig;
            _mtgjsonSourceConfig = mtgjsonSourceConfig;
            _updateAppDir        = AppDir.Update.AddPath("app");

            _appOnlineSignatureFile     = Path.Combine(_updateAppDir, Signer.SignaturesFile);
            _appDownloadedSignatureFile = AppDir.Update.AddPath(Signer.SignaturesFile);
            _appInstalledVersionFile    = AppDir.Update.AddPath("version.txt");

            AppDownloadedSignature = getAppDownloadedSignature();

            _webClient = new WebClientBase();
            _megatools = new Megatools();

            _protectedFiles = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase)
            {
                AppDir.GeneralConfigXml,
                AppDir.DisplayConfigXml,
                cardSearcher.IndexDirectory.AddPath("*.*"),
                cardSearcher.Spellchecker.IndexDirectory.AddPath("*.*"),
                keywordSearcher.IndexDirectory.AddPath("*.*")
            };
        }
Beispiel #2
0
        private void downloadSignatures(QualityGroupConfig qualityGroup)
        {
            if (qualityGroup.FileListMegaId == null && qualityGroup.FileListGdriveId == null)
            {
                return;
            }

            string signaturesDir     = Path.Combine(_updateImgDir, qualityGroup.Quality);
            string signaturesFile    = Path.Combine(signaturesDir, Signer.SignaturesFile);
            string signaturesFileBak = signaturesFile + ".bak";

            if (File.Exists(signaturesFile))
            {
                if (File.Exists(signaturesFileBak))
                {
                    File.Delete(signaturesFileBak);
                }

                File.Move(signaturesFile, signaturesFileBak);
            }

            if (qualityGroup.FileListMegaId != null)
            {
                string megaUrl = _config.MegaPrefix + qualityGroup.FileListMegaId;
                _megatools.Download(megaUrl, signaturesDir, $"Signatures for {qualityGroup.Quality} images", silent: true);
            }
            else if (qualityGroup.FileListGdriveId != null)
            {
                var    webClient       = new WebClientBase();
                string gdriveUrl       = _config.GdrivePrefix + qualityGroup.FileListGdriveId;
                string fileListArchive = signaturesDir.AddPath("filelist.7z");
                Console.WriteLine($"Downloading {fileListArchive} from {gdriveUrl}");
                webClient.DownloadFile(gdriveUrl, fileListArchive);
                new SevenZip(silent: true).Extract(fileListArchive, signaturesDir);
            }

            if (!File.Exists(signaturesFile))
            {
                if (File.Exists(signaturesFileBak))
                {
                    Console.WriteLine("Failed to download signatures");

                    Console.WriteLine("Move {0} {1}", signaturesFileBak, signaturesFile);
                    File.Move(signaturesFileBak, signaturesFile);
                }
            }
            else
            {
                File.Delete(signaturesFileBak);
            }
        }
Beispiel #3
0
        private void downloadNews()
        {
            Console.Write("Fetching update news... ");

            try
            {
                var webClient = new WebClientBase();
                webClient.DownloadFile(_appSourceConfig.NewsUrl, _newsArchive);

                Console.WriteLine("done");
            }
            catch (Exception ex)
            {
                _log.Info(ex, "Download news failed");
                Console.WriteLine("failed");
            }

            Console.WriteLine();
        }
Beispiel #4
0
        private async Task downloadNews(CancellationToken token)
        {
            Console.Write("Fetching update news... ");

            try
            {
                var webClient = new WebClientBase();
                await webClient.DownloadFile(_appSourceConfig.NewsUrl, _newsArchive, token);

                Console.WriteLine("done");
            }
            catch (Exception ex)
            {
                _log.Info(ex, "Download news failed");
                Console.WriteLine("failed");
            }

            Console.WriteLine();
        }
Beispiel #5
0
        [UsedImplicitly]         // by ninject
        public Installer(
            AppSourceConfig appSourceConfig,
            MtgjsonSourceConfig mtgjsonSourceConfig)
        {
            _appSourceConfig     = appSourceConfig;
            _mtgjsonSourceConfig = mtgjsonSourceConfig;
            _updateAppDir        = AppDir.Update.Join("app");

            _appOnlineSignatureFile     = _updateAppDir.Join(Signer.SignaturesFile);
            _appDownloadedSignatureFile = AppDir.Update.Join(Signer.SignaturesFile);
            _appInstalledVersionFile    = AppDir.Update.Join("version.txt");

            AppDownloadedSignature = getAppDownloadedSignature();

            _webClient = new WebClientBase();

            _protectedFiles = new HashSet <FsPath>
            {
                AppDir.GeneralConfigXml,
                AppDir.DisplayConfigXml,
            };
        }