public void ForceReset() { _watcher.EnableRaisingEvents = false; try { Directory.Delete(Path.Combine(Environment.CurrentDirectory, "downloaded"), true); Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, "downloaded")); Versions = GetTags(Properties.Settings.Default.Repo); foreach (var version in Versions) { DownloadDefinitions(version.Commit.Sha); } _latestCommit = GetLatestCommit(); DownloadDefinitions(_latestCommit.Sha); } catch (Exception exc) { new ExtendedErrorView("[Versioning] Failed to reset definitions.", exc.ToString(), "Error") .ShowDialog(); } }
public Versioning() { try { if (!Directory.Exists(Path.Combine(Environment.CurrentDirectory, "downloaded"))) { Directory.CreateDirectory("downloaded"); Versions = GetTags(Properties.Settings.Default.Repo); _latestCommit = GetLatestCommit(); } else { Versions = GetTags(Properties.Settings.Default.Repo); _latestCommit = GetLatestCommit(); return; } foreach (var version in Versions) { DownloadDefinitions(version.Commit.Sha); } DownloadDefinitions(_latestCommit.Sha); } catch (Exception exc) { new ExtendedErrorView("[Versioning] Failed to reset definitions.", exc.ToString(), "Error") .ShowDialog(); } }
public static GithubApiCommits GetNewestCommit() { using (WebClient client = new WebClient()) { client.Headers.Add("User-Agent", "XIVMon"); var result = client.DownloadString($"https://api.github.com/repos/{Repo}/commits"); return(GithubApiCommits.FromJson(result)[0]); } }
private GithubApiCommits GetLatestCommit() { if (File.Exists(Path.Combine("downloaded", "commits.json"))) { return(Commits.GithubApiCommits.FromJson(File.ReadAllText(Path.Combine("downloaded", "commits.json")))[0]); } using (WebClient client = new WebClient()) { client.Headers.Add("User-Agent", "XIVMon"); var result = client.DownloadString($"https://api.github.com/repos/{Properties.Settings.Default.Repo}/commits"); File.WriteAllText(Path.Combine("downloaded", "commits.json"), result); return(GithubApiCommits.FromJson(result)[0]); } }
public void ForceReset() { if (_watcher != null) { _watcher.EnableRaisingEvents = false; } try { Directory.Delete(Path.Combine(Environment.CurrentDirectory, "downloaded"), true); while (Directory.Exists(Path.Combine(Environment.CurrentDirectory, "downloaded"))) { ; // These are here because Windows is retarded and takes it's time with updating the FS } Directory.CreateDirectory("downloaded"); while (!Directory.Exists(Path.Combine(Environment.CurrentDirectory, "downloaded"))) { ; } Versions = GetTags(Properties.Settings.Default.Repo, true); foreach (var version in Versions) { DownloadDefinitions(version.Commit.Sha); } _latestCommit = GetLatestCommit(); DownloadDefinitions(_latestCommit.Sha); } catch (Exception exc) { new ExtendedErrorView("[Versioning] Failed to reset definitions.", exc.ToString(), "Error") .ShowDialog(); #if DEBUG throw exc; #endif } }
public Versioning() { try { if (!Directory.Exists(Path.Combine(Environment.CurrentDirectory, "downloaded"))) { Properties.Settings.Default.Repo = Resources.DefaultRepo; Properties.Settings.Default.Save(); MessageBox.Show( $"Could not find downloaded database - repo reset to {Resources.DefaultRepo}, change via Options -> Set Repository.", "FFXIVMon Reborn", MessageBoxButton.OK, MessageBoxImage.Information); Directory.CreateDirectory("downloaded"); Versions = GetTags(Properties.Settings.Default.Repo); _latestCommit = GetLatestCommit(); } else { Versions = GetTags(Properties.Settings.Default.Repo); _latestCommit = GetLatestCommit(); return; } foreach (var version in Versions) { DownloadDefinitions(version.Commit.Sha); } DownloadDefinitions(_latestCommit.Sha); } catch (Exception exc) { new ExtendedErrorView("[Versioning] Failed to reset definitions.", exc.ToString(), "Error") .ShowDialog(); } }