Skip to content

Commit

Permalink
Merge pull request #34 from martial-god/Dev
Browse files Browse the repository at this point in the history
update the -u method wording
  • Loading branch information
feahnthor authored Nov 3, 2023
2 parents 9378071 + bb2e471 commit 3572428
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Benny-Scraper/Benny-Scraper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Version>1.1.0</Version>
<Version>1.1.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
20 changes: 9 additions & 11 deletions Benny-Scraper/Program.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -655,7 +659,6 @@ public static async Task DisplayNovelInformationAsync(Guid novelId)
};

Console.WriteLine("NOVEL INFORMATION:");
Console.WriteLine();
Console.WriteLine("-------------------");
foreach (var detail in details)
{
Expand All @@ -667,16 +670,17 @@ 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
{
var response = await client.GetStringAsync(url);
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)
{
Expand Down Expand Up @@ -715,15 +719,13 @@ private static async Task<bool> DownloadAndUpgradeApp(string downloadUrl, string

try
{
// Extract the ZIP
string tempDirectory = Path.Combine(Path.GetTempPath(), "appUpdate");
if (Directory.Exists(tempDirectory))
Directory.Delete(tempDirectory, true);
ZipFile.ExtractToDirectory(tempFile, tempDirectory);

// Stop services or processes if necessary

// Replace files
foreach (var file in Directory.GetFiles(tempDirectory))
{
string destFile = Path.Combine(installDirectory, Path.GetFileName(file));
Expand All @@ -738,12 +740,9 @@ private static async Task<bool> 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)
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Benny-Scraper/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
},
"Benny-Scraper": {
"commandName": "Project",
"commandLineArgs": "-u",
"nativeDebugging": true
}
}
Expand Down

0 comments on commit 3572428

Please sign in to comment.