Skip to content

Commit

Permalink
Fix crash for rate limit exceeded checking for new versions of Invent…
Browse files Browse the repository at this point in the history
…ory Kamera
  • Loading branch information
Cupcak3 committed Sep 10, 2023
1 parent 1c16150 commit 9312079
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions InventoryKamera/ui/main/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,23 +490,27 @@ private void MainForm_Shown(object sender, EventArgs e)
private async void CheckForKameraUpdates()
{
var client = new GitHubClient(new ProductHeaderValue("Inventory_Kamera"));
var releases = await client.Repository.Release.GetAll("Andrewthe13th", "Inventory_Kamera");
var latest = releases.First();
try
{
var releases = await client.Repository.Release.GetAll("Andrewthe13th", "Inventory_Kamera");
var latest = releases.First();


Version latestVersion = new Version(Regex.Replace(latest.TagName, "[a-zA-Z]", string.Empty));
Version currentVersion = Assembly.GetExecutingAssembly().GetName().Version;
if (currentVersion.CompareTo(latestVersion) < 0)
{
var message = $"A new version of Inventory Kamera is available.\n\n" +
$"Current Version: {currentVersion}\nLatest Version: {latestVersion}\n\n" +
$"Would you like to download the update?";
var result = MessageBox.Show(message, "Inventory Kamera Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
Version latestVersion = new Version(Regex.Replace(latest.TagName, "[a-zA-Z]", string.Empty));
Version currentVersion = Assembly.GetExecutingAssembly().GetName().Version;
if (currentVersion.CompareTo(latestVersion) < 0)
{
Process.Start(new ProcessStartInfo(latest.HtmlUrl) { UseShellExecute = true });
var message = $"A new version of Inventory Kamera is available.\n\n" +
$"Current Version: {currentVersion}\nLatest Version: {latestVersion}\n\n" +
$"Would you like to download the update?";
var result = MessageBox.Show(message, "Inventory Kamera Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
Process.Start(new ProcessStartInfo(latest.HtmlUrl) { UseShellExecute = true });
}
}
}
catch (RateLimitExceededException) { Logger.Warn("Rate limit exceeded checking for Kamera Update!!!! This warning should be resolved in an hour."); }

}

Expand Down

0 comments on commit 9312079

Please sign in to comment.