From bb2e471ea8f7a3a2d4ed3bee4109bff2934873a6 Mon Sep 17 00:00:00 2001 From: Henry F Date: Thu, 2 Nov 2023 20:27:19 -0500 Subject: [PATCH] update the -u method wording --- Benny-Scraper/Benny-Scraper.csproj | 2 +- Benny-Scraper/Program.cs | 20 +++++++++----------- Benny-Scraper/Properties/launchSettings.json | 1 + 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Benny-Scraper/Benny-Scraper.csproj b/Benny-Scraper/Benny-Scraper.csproj index 6b1a5b7..02c9b8c 100644 --- a/Benny-Scraper/Benny-Scraper.csproj +++ b/Benny-Scraper/Benny-Scraper.csproj @@ -7,7 +7,7 @@ enable enable app.manifest - 1.1.0 + 1.1.1 diff --git a/Benny-Scraper/Program.cs b/Benny-Scraper/Program.cs index 9bda071..3111819 100644 --- a/Benny-Scraper/Program.cs +++ b/Benny-Scraper/Program.cs @@ -1,6 +1,7 @@ using System.Diagnostics; using System.IO.Compression; using System.Text; +using System.Xml; using Autofac; using Benny_Scraper.BusinessLogic; using Benny_Scraper.BusinessLogic.Config; @@ -33,7 +34,10 @@ internal class Program private static IContainer Container { get; set; } private const string AreYouSure = "Are you sure you want to {0}? (y/n)"; private const int MaxTitleWidth = 50; - private const string ProgramVersion = "v1.1.0"; + private const string ProgramVersion = "v1.1.1"; + private const string ReleaseUrl = "https://api.github.com/repos/martial-god/Benny-Scraper/releases/latest"; + private const string MainProject = "Benny-Scraper.csproj"; + public static IConfiguration Configuration { get; set; } // Added Task to Main in order to avoid "Program does not contain a static 'Main method suitable for an entry point" @@ -655,7 +659,6 @@ public static async Task DisplayNovelInformationAsync(Guid novelId) }; Console.WriteLine("NOVEL INFORMATION:"); - Console.WriteLine(); Console.WriteLine("-------------------"); foreach (var detail in details) { @@ -667,8 +670,8 @@ public static async Task DisplayNovelInformationAsync(Guid novelId) private static async Task CheckAndUpgrade() { using HttpClient client = new HttpClient(); - string url = "https://api.github.com/repos/martial-god/Benny-Scraper/releases/latest"; - client.DefaultRequestHeaders.Add("User-Agent", "Benny-Scraper"); // GitHub API requires a User-Agent + string url = ReleaseUrl; + client.DefaultRequestHeaders.Add("User-Agent", "Benny-Scraper"); try { @@ -676,7 +679,8 @@ private static async Task CheckAndUpgrade() var jsonResponse = Newtonsoft.Json.Linq.JObject.Parse(response); string latestVersion = jsonResponse["tag_name"].ToString(); - string currentVersion = ProgramVersion; // figure out how to get the current version from csproj + string currentVersion = ProgramVersion; + Console.WriteLine($"Current version: {currentVersion}"); if (string.Compare(latestVersion, currentVersion, StringComparison.InvariantCultureIgnoreCase) > 0) { @@ -715,7 +719,6 @@ private static async Task DownloadAndUpgradeApp(string downloadUrl, string try { - // Extract the ZIP string tempDirectory = Path.Combine(Path.GetTempPath(), "appUpdate"); if (Directory.Exists(tempDirectory)) Directory.Delete(tempDirectory, true); @@ -723,7 +726,6 @@ private static async Task DownloadAndUpgradeApp(string downloadUrl, string // Stop services or processes if necessary - // Replace files foreach (var file in Directory.GetFiles(tempDirectory)) { string destFile = Path.Combine(installDirectory, Path.GetFileName(file)); @@ -738,12 +740,9 @@ private static async Task DownloadAndUpgradeApp(string downloadUrl, string Directory.Move(dir, destDir); } - // Clean up File.Delete(tempFile); Directory.Delete(tempDirectory, true); - // Restart services or application if necessary - return true; } catch (Exception ex) @@ -790,7 +789,6 @@ private static async Task UpdateNovelFileType(Guid id) Logger.Error($"Exception when trying to update novel file type. {ex.Message}"); } } - #endregion #region Setup diff --git a/Benny-Scraper/Properties/launchSettings.json b/Benny-Scraper/Properties/launchSettings.json index dd1e951..000fada 100644 --- a/Benny-Scraper/Properties/launchSettings.json +++ b/Benny-Scraper/Properties/launchSettings.json @@ -6,6 +6,7 @@ }, "Benny-Scraper": { "commandName": "Project", + "commandLineArgs": "-u", "nativeDebugging": true } }