public static bool CheckUpdatable() { var option = SettingManager.LoadSetting <GlobalSetting>(); try { var releases = UpdaterHelper.GetGithubAllReleaseInfoList("MikiraSora", "Wbooru"); if (!releases.Any()) { Log.Info($"There is no any release info ,skip update check."); return(false); } var updatable_releases = releases.Where(x => x.Version > CurrentProgramVersion) .OrderByDescending(x => x.Version); CacheUpdatableReleaseInfo = (option.UpdatableTargetVersion == GlobalSetting.UpdatableTarget.Preview ? updatable_releases.FirstOrDefault(x => x.ReleaseType == ReleaseType.Preview) : null) ?? updatable_releases.FirstOrDefault(x => x.ReleaseType == ReleaseType.Stable); if (CacheUpdatableReleaseInfo == null) { Log.Info($"There is no any updatable({option.UpdatableTargetVersion}) release info ,skip update check."); return(false); } return(true); } catch (Exception e) { Log.Error("Updater occured error : " + e.Message); return(false); } }
private void BtnAddSub_Click(object sender, EventArgs e) { using (StringInputDialog d = new StringInputDialog("Github link to a repository:", "")) { if (d.ShowDialog(this) == DialogResult.OK) { Regex rgx = new Regex(".*[Gg][Ii][Tt][Hh][Uu][Bb][.][Cc][Oo][Mm]/([^/\n]+)/([^/\n]+)[^\n]*"); Match m = rgx.Match(d.resultString); if (m.Success && m.Groups.Count == 3) { string repoOwner = m.Groups[1].Value; string repoName = m.Groups[2].Value; if (repoOwner.Equals("soopercool101", StringComparison.OrdinalIgnoreCase) || MessageBox.Show( $"Warning: The {repoOwner}/{repoName} repository is not affiliated with the BrawlCrate Developement Team.\n" + "You should only install scripts from sources you trust. Would you like to proceed?", "API Subscription Updater", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { UpdaterHelper.BrawlAPIInstallUpdate(true, repoOwner, repoName, true); GetNewFiles(); RefreshList(); } } else { MessageBox.Show($"{d.resultString} is not a valid GitHub repository.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public static void Main(string[] args) { Eager.Initalize(); //Update Line //Check if an parameter was passed if (args.Length == 0) { return; } //Wait for all update files to be applied while (UpdaterHelper.Updating()) { } //Spawn the process that originally called this program var param = ""; if (args.Length > 1) { param = args[1]; } SpawnParentProgram(args[0], param); }
private static void SelfUpdate(GitHubUpdater updater) { // var updater = new GitHubUpdater(); updater.SetRepo("jcaillon", "GithubUpdater"); updater.UseCancellationToken(new CancellationTokenSource(3000).Token); updater.UseMaxNumberOfReleasesToFetch(10); var currentVersion = UpdaterHelper.StringToVersion(FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion); Console.WriteLine($"Our current version is: {currentVersion}."); var releases = updater.FetchNewReleases(currentVersion); Console.WriteLine($"We found {releases.Count} new releases on github."); Console.WriteLine($"The latest release if {releases[0].Name}."); Console.WriteLine($"Downloading the latest release asset: {releases[0].Assets[0].BrowserDownloadUrl}."); var tempFilePath = updater.DownloadToTempFile(releases[0].Assets[0].BrowserDownloadUrl, progress => { Console.WriteLine($"Downloading... {progress.NumberOfBytesDoneTotal} / {progress.NumberOfBytesTotal} bytes."); }); var fileUpdater = SimpleFileUpdater.Instance; Console.WriteLine("We will replace this .exe with the one on the github release after this program has exited."); fileUpdater.AddFileToMove(tempFilePath, Assembly.GetExecutingAssembly().Location); fileUpdater.Start(); }
private void OnBeforeShow() { _menuListener.RunCommand(MenuKeys.Welcome); UpdaterHelper.GetLatestVersion(); }
private void OnBeforeShow() { if (AppConfig.Instance.ShowWelcomeDialog) { _menuListener.RunCommand(MenuKeys.Welcome); } UpdaterHelper.GetLatestVersion(); }
private void BtnUninstall_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(selected)) { string[] repoData = selected.Split('/'); UpdaterHelper.BrawlAPIUninstall(true, repoData[0], repoData[1], true); RefreshList(); LstSubs_ItemChanged(sender, null); } }
private static SplashForm splash;// = new SplashForm(); internal static void Launch() { Application.CurrentCulture = CultureInfo.InvariantCulture; Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); splash = new SplashForm(); splash.Show(); Timer timer = new Timer(); //Configure this timer to restart each second ( 1000 millis) timer.Interval = 1000; timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); timer.Start(); //splash.Refresh(); //Application.DoEvents(); Application.DoEvents(); MainModule.Initialize("data"); splash.SetLoadProgress(50); splash.Refresh(); Application.DoEvents(); UpdaterHelper.UpdateInfo info; info = UpdaterHelper.CheckFromUpdates(); Application.DoEvents(); if (info.UpdateAvailable) { UpdateForm updateForm; updateForm = new UpdateForm(info); updateForm.ShowDialog(); Application.DoEvents(); } splash.SetLoadProgress(60); splash.Refresh(); Application.DoEvents(); IconsManager.Initialize(); Application.DoEvents(); MainForm main = new MainForm(); //if (runSingleInstance) //{ // main.HandleCreated += new EventHandler(main_HandleCreated); //} GC.Collect(); timer.Stop(); timer.Close(); splash.SetLoadProgress(100); splash.Refresh(); Application.DoEvents(); splash.Close(); splash = null; Application.DoEvents(); Application.Run(main); } //Launch
public static void Main(string[] args) { Eager.Initalize(); if (args.Length > 0) { Log.FilePath = args[0]; Log.Output = Log.Mode.File; } UpdaterHelper.ApplyUpdate <WindowsUpdate, MacUpdate, LinuxUpdate>("FOGService"); }
static void Main() { IUpdater updater = UpdaterHelper.GetInstance("MyAuto"); if (updater.Run()) { return; } Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FormMain()); }
private PluginMarketPost BuildPluginMarketPost(JToken post_json) { var post = UpdaterHelper.BuildInstance <PluginMarketPost>(post_json); if ("GithubRelease".Equals(post.ReleaseType, StringComparison.InvariantCultureIgnoreCase)) { post.ReleaseInfos = UpdaterHelper.GetPostReleaseInfosFromGithubRelease(post.ReleaseUrl).ToArray(); } else { post.ReleaseInfos = UpdaterHelper.GetPostReleaseInfosFromIssueCommentsAPI(post_json["comments_url"].ToString()).ToArray(); post.ReleaseUrl = string.IsNullOrWhiteSpace(post.ReleaseUrl) ? post_json["html_url"].ToString() : post.ReleaseUrl; } return(post); }
public IEnumerable <ReleaseInfo> GetReleaseInfoList() { return(UpdaterHelper.GetGithubAllReleaseInfoList("Wbooru", "WbooruPlugin.CommonMoebooruGallery")); }
public IEnumerable <ReleaseInfo> GetReleaseInfoList() { return(UpdaterHelper.GetGithubAllReleaseInfoList("Wbooru", "WbooruPlugin.Danbooru")); }
public void Test() { // hostname to use // we need something different than 127.0.0.1 or localhost for the proxy! IPHostEntry hostEntry; try { hostEntry = Dns.GetHostEntry("mylocalhost"); } catch (Exception) { hostEntry = null; } var host = hostEntry == null ? "127.0.0.1" : "mylocalhost"; var baseDir = Path.Combine(TestFolder, "http"); Directory.CreateDirectory(baseDir); var githubServer = new SimpleGithubServer(baseDir, "admin"); var proxyServer = new SimpleHttpProxyServer("jucai69d", "julien caillon"); githubServer.Releases = new List <GitHubRelease> { new GitHubRelease { CreatedAt = $"{DateTime.UtcNow:s}Z" } }; var cts = new CancellationTokenSource(); var task1 = HttpServer.ListenAsync(8084, cts.Token, githubServer.OnHttpRequest, true); var task2 = HttpServer.ListenAsync(8085, cts.Token, proxyServer.OnHttpRequest, true); // do githubServer.Releases = new List <GitHubRelease> { new GitHubRelease { Name = "rel1", TagName = "v1.0.1-beta", Prerelease = true, ZipballUrl = "file.v1.0", CreatedAt = $"{DateTime.UtcNow:s}Z", Assets = new List <GitHubAsset> { new GitHubAsset { Name = "asset1" }, new GitHubAsset { Name = "asset2" } } }, new GitHubRelease { Name = "rel2", TagName = "v1.1.0", Prerelease = false }, new GitHubRelease { Name = "rel3", TagName = "v1.2.1-beta", Prerelease = true }, new GitHubRelease { Name = "rel5", TagName = "v3.0.0", Prerelease = false }, new GitHubRelease { Name = "rel4", TagName = "v2.0.0", Prerelease = false } }; var updater = new GitHubUpdater(); updater.UseAuthorizationToken("admin"); updater.UseAlternativeBaseUrl($"http://{host}:8084"); updater.UseProxy($"http://{host}:8085/", "jucai69d", "julien caillon"); updater.SetRepo("3pUser", "yolo"); updater.UseMaxNumberOfReleasesToFetch(10); var releases = updater.FetchNewReleases(UpdaterHelper.StringToVersion("0")); Assert.AreEqual(5, releases.Count); Assert.AreEqual("rel5", releases[0].Name); releases = updater.FetchNewReleases(UpdaterHelper.StringToVersion("3")); Assert.AreEqual(0, releases.Count); releases = updater.FetchNewReleases(UpdaterHelper.StringToVersion("1.2")); Assert.AreEqual(3, releases.Count); Assert.AreEqual("rel5", releases[0].Name); File.WriteAllText(Path.Combine(baseDir, "testFile"), "cc"); var countProgress = 0; var dlPath = updater.DownloadToTempFile("testFile", progress => countProgress++); Assert.IsTrue(countProgress > 0); Assert.IsTrue(File.Exists(dlPath)); Assert.AreEqual(File.ReadAllText(Path.Combine(baseDir, "testFile")), File.ReadAllText(dlPath)); File.Delete(dlPath); if (!host.Equals("127.0.0.1")) { Assert.IsTrue(proxyServer.NbRequestsHandledOk > 0); } HttpServer.Stop(cts, task1, task2); }
private void BtnUpdateSubscriptions_Click(object sender, EventArgs e) { UpdaterHelper.BrawlAPICheckUpdates(true, true); GetNewFiles(); RefreshList(); }
public void TestTGAll() { // force request version result // UpdaterRequestVersionHandler.DebugVersionResult = 2; var isDebug = true; var urlPrefix = "http://sjres.icantw.com/g1-resources-package/trunk"; var namePrefix = "g1.resources.trunk.1.2.0"; var upHandlers = UpdaterHelper.CreateAllUpdater("./TestUpdate", urlPrefix, namePrefix, ".resource_version", isDebug); UpdaterDecompressHandler.OnDecompressedEvent += OnDecompressEvent; PatchListFile.PatchListCustomWriter = (bytes) => { for (var i = 0; i < bytes.Length; i++) { bytes[i] ^= 1; } return(bytes); }; PatchListFile.PatchListCustomReader = (patchListPath) => { var bytes = File.ReadAllBytes(patchListPath); for (var i = 0; i < bytes.Length; i++) { bytes[i] ^= 1; } var stream = new MemoryStream(bytes); return(new StreamReader(stream)); }; var updater = new Updater(upHandlers); updater.OnTransitionEvent += (current, next) => { Console.WriteLine("----------------\n[OnTransitionEvent:{0}]\n{1}\n----------------", current.GetType(), current.GetLogs()); }; var thread = updater.StartThread(); while (!thread.IsDone) { Console.WriteLine("{0} : {1}%", thread.CurrentHandler, thread.Progress * 100d); if (thread.CurrentHandler is UpdaterDownloadPackageHandler) { var downloader = thread.CurrentHandler as UpdaterDownloadPackageHandler; Console.WriteLine("TotalSize: " + downloader.TotalDownloadSize); Console.WriteLine("DownloadSize: " + downloader.DownloadedSize); } Thread.Sleep(1); } // Check if RequestVersionHandler error, ignore Console.WriteLine(thread.Progress); if (thread.IsError) { Console.WriteLine("Error: {0}, Handler: {1}", thread.Error, thread.ErrorHandler); } Assert.False(thread.IsError); var checkVersionHandler = upHandlers[4] as UpdaterCheckVersionHandler; if (isDebug && checkVersionHandler.IsFinished && checkVersionHandler.LocalVersion != checkVersionHandler.RemoteVersion) { // 证明需要更新 // downloadHandler var downloader = upHandlers[5] as UpdaterDownloadPackageHandler; var zipPath = downloader.GetSavePath(); Assert.True(File.Exists(zipPath)); } }
/// <summary> /// Returns a list of new releases based on the local version versus the tag version of distant releases. /// The returned list is sorted by descending order, the first release being the most up-to-date. /// </summary> /// <param name="localVersion">See <see cref="UpdaterHelper.StringToVersion"/> to get the version from a string.</param> /// <returns></returns> public List <GitLabTag> FetchNewReleases(Version localVersion) { return(FetchNewReleases(release => UpdaterHelper.StringToVersion(release.TagName).CompareTo(localVersion) > 0, release => UpdaterHelper.StringToVersion(release.TagName))); }
public void Test() { // hostname to use // we need something different than 127.0.0.1 or localhost for the proxy! IPHostEntry hostEntry; try { hostEntry = Dns.GetHostEntry("mylocalhost"); } catch (Exception) { hostEntry = null; } var host = hostEntry == null ? "127.0.0.1" : "mylocalhost"; var baseDir = Path.Combine(TestFolder, "http"); Directory.CreateDirectory(baseDir); var gitLabServer = new SimpleGitLabServer(baseDir, "admin"); var proxyServer = new SimpleHttpProxyServer("jucai69d", "julien caillon"); var cts = new CancellationTokenSource(); var task1 = HttpServer.ListenAsync(8086, cts.Token, gitLabServer.OnHttpRequest, true); var task2 = HttpServer.ListenAsync(8087, cts.Token, proxyServer.OnHttpRequest, true); // do gitLabServer.Tags = new List <GitLabTag> { new GitLabTag { TagName = "v1.0.1-beta", TagMessage = "rel1", TagSha1 = "1", Release = new GitLabRelease { TagName = "", Description = "Description" } }, new GitLabTag { TagName = "v1.1.0", TagMessage = "rel2", TagSha1 = "2" }, new GitLabTag { TagName = "v1.2.1-beta", TagMessage = "rel3", TagSha1 = "3" }, new GitLabTag { TagName = "v3.0.0", TagMessage = "rel5", TagSha1 = "5" }, new GitLabTag { TagName = "v2.0.0", TagMessage = "rel4", TagSha1 = "4" } }; var updater = new GitLabUpdater($"http://{host}:8086"); updater.UsePrivateToken("admin"); updater.UseProxy($"http://{host}:8087/", "jucai69d", "julien caillon"); updater.SetProjectId("test/truc"); updater.UseMaxNumberOfTagsToFetch(10); var tags = updater.FetchNewReleases(UpdaterHelper.StringToVersion("0")); Assert.AreEqual(5, tags.Count); Assert.AreEqual("rel5", tags[0].TagMessage); tags = updater.FetchNewReleases(UpdaterHelper.StringToVersion("3")); Assert.AreEqual(0, tags.Count); tags = updater.FetchNewReleases(UpdaterHelper.StringToVersion("1.2")); Assert.AreEqual(3, tags.Count); Assert.AreEqual("rel5", tags[0].TagMessage); File.WriteAllText(Path.Combine(baseDir, "testFile"), "cc"); var countProgress = 0; var dlPath = updater.DownloadToTempFile("testFile", progress => countProgress++); Assert.IsTrue(countProgress > 0); Assert.IsTrue(File.Exists(dlPath)); Assert.AreEqual(File.ReadAllText(Path.Combine(baseDir, "testFile")), File.ReadAllText(dlPath)); File.Delete(dlPath); countProgress = 0; dlPath = updater.DownloadRepositoryArchive("mysha1", progress => countProgress++); Assert.IsTrue(countProgress > 0); Assert.IsTrue(File.Exists(dlPath)); Assert.AreEqual(new FileInfo(dlPath).Length, 10); File.Delete(dlPath); if (!host.Equals("127.0.0.1")) { Assert.IsTrue(proxyServer.NbRequestsHandledOk > 0); } HttpServer.Stop(cts, task1, task2); }
public IEnumerable <ReleaseInfo> GetReleaseInfoList() { return(UpdaterHelper.GetPostReleaseInfosFromIssue("https://github.com/MikiraSora/Wbooru.PluginsMarket/issues/2")); }