Example #1
0
        public static void EnsureWCR()
        {
            try
            {
                string API = "https://api.github.com/repos/marcussacana/WebComicReader/branches";

                string WCR     = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "WCR");
                string Version = Path.Combine(WCR, "version");

                bool Outdated = false;
                if (!File.Exists(Version))
                {
                    Outdated = true;
                }

                if (WCRLastCommit == null)
                {
                    var Resp = Encoding.UTF8.GetString(API.TryDownload(UserAgent: ProxyTools.UserAgent) ?? new byte[0]);
                    WCRLastCommit = DataTools.ReadJson(Resp.Substring("gh-pages", "protected"), "url").Split('/').Last();
                }

                if (!Outdated)
                {
                    var LocalCommit = File.ReadAllText(Version).Trim();
                    Outdated = WCRLastCommit != LocalCommit;
                }

                if (!Outdated)
                {
                    return;
                }

                string Url          = "https://github.com/marcussacana/WebComicReader/archive/gh-pages.zip";
                string SaveAs       = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "WCR.zip");
                string ExtractedDir = Path.Combine(Path.GetDirectoryName(CurrentAssembly), "WebComicReader-gh-pages");

                string DbgPath = AppDomain.CurrentDomain.BaseDirectory;


                DownloadingWindow Window = new DownloadingWindow(Url, SaveAs);
                Window.ShowDialog();

                ZipFile Zip = new ZipFile(SaveAs);
                Zip.ExtractAll(Path.GetDirectoryName(CurrentAssembly), ExtractExistingFileAction.OverwriteSilently);
                Zip.Dispose();

                if (Directory.Exists(WCR))
                {
                    Directory.Delete(WCR, true);
                }

                Directory.Move(ExtractedDir, WCR);

                File.Delete(SaveAs);

                File.WriteAllText(Version, WCRLastCommit);
            }
            catch
            {
                return;
            }
        }
Example #2
0
        private static void CefUpdater()
        {
            string CefRepo = "https://raw.githubusercontent.com/marcussacana/MangaUnhost/data/";

            bool Outdated = false;

            if (!File.Exists(BrowserSubprocessPath))
            {
                Outdated = true;
            }

            if (!Outdated)
            {
                var VerStr = FileVersionInfo.GetVersionInfo(BrowserSubprocessPath).FileVersion;
                if (new Version(VerStr) != new Version(75, 1, 143, 0))
                //if (new Version(VerStr) != new Version(79, 1, 360, 0))
                {
                    Outdated = true;
                }
            }

            if (!File.Exists(LibWebP))
            {
                Outdated = true;
            }

            if (!Outdated)
            {
                return;
            }

            string CEFName = $"CEF{(Environment.Is64BitProcess ? "x64" : "x86")}.zip";
            string Url     = $"{CefRepo}{CEFName}";
            string SaveAs  = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, CEFName);

            string DbgPath = AppDomain.CurrentDomain.BaseDirectory;

            for (int i = 0; i < 4; i++)
            {
                DbgPath = Path.GetDirectoryName(DbgPath);

                if (Debug && File.Exists(Path.Combine(DbgPath, CEFName)))
                {
                    ZipFile DZip = new ZipFile(Path.Combine(DbgPath, CEFName));
                    DZip.ExtractAll(Path.GetDirectoryName(CurrentAssembly), ExtractExistingFileAction.OverwriteSilently);
                    DZip.Dispose();
                    return;
                }
            }


            DownloadingWindow Window = new DownloadingWindow(Url, SaveAs);

            Application.Run(Window);

            ZipFile Zip = new ZipFile(SaveAs);

            Zip.ExtractAll(Path.GetDirectoryName(CurrentAssembly), ExtractExistingFileAction.OverwriteSilently);
            Zip.Dispose();

            File.Delete(SaveAs);
        }