1
1
using System . Diagnostics ;
2
2
using System . IO . Compression ;
3
3
using System . Text ;
4
+ using System . Xml ;
4
5
using Autofac ;
5
6
using Benny_Scraper . BusinessLogic ;
6
7
using Benny_Scraper . BusinessLogic . Config ;
@@ -33,7 +34,10 @@ internal class Program
33
34
private static IContainer Container { get ; set ; }
34
35
private const string AreYouSure = "Are you sure you want to {0}? (y/n)" ;
35
36
private const int MaxTitleWidth = 50 ;
36
- private const string ProgramVersion = "v1.1.0" ;
37
+ private const string ProgramVersion = "v1.1.1" ;
38
+ private const string ReleaseUrl = "https://api.github.com/repos/martial-god/Benny-Scraper/releases/latest" ;
39
+ private const string MainProject = "Benny-Scraper.csproj" ;
40
+
37
41
public static IConfiguration Configuration { get ; set ; }
38
42
39
43
// 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)
655
659
} ;
656
660
657
661
Console . WriteLine ( "NOVEL INFORMATION:" ) ;
658
- Console . WriteLine ( ) ;
659
662
Console . WriteLine ( "-------------------" ) ;
660
663
foreach ( var detail in details )
661
664
{
@@ -667,16 +670,17 @@ public static async Task DisplayNovelInformationAsync(Guid novelId)
667
670
private static async Task CheckAndUpgrade ( )
668
671
{
669
672
using HttpClient client = new HttpClient ( ) ;
670
- string url = "https://api.github.com/repos/martial-god/Benny-Scraper/releases/latest" ;
671
- client . DefaultRequestHeaders . Add ( "User-Agent" , "Benny-Scraper" ) ; // GitHub API requires a User-Agent
673
+ string url = ReleaseUrl ;
674
+ client . DefaultRequestHeaders . Add ( "User-Agent" , "Benny-Scraper" ) ;
672
675
673
676
try
674
677
{
675
678
var response = await client . GetStringAsync ( url ) ;
676
679
var jsonResponse = Newtonsoft . Json . Linq . JObject . Parse ( response ) ;
677
680
678
681
string latestVersion = jsonResponse [ "tag_name" ] . ToString ( ) ;
679
- string currentVersion = ProgramVersion ; // figure out how to get the current version from csproj
682
+ string currentVersion = ProgramVersion ;
683
+ Console . WriteLine ( $ "Current version: { currentVersion } ") ;
680
684
681
685
if ( string . Compare ( latestVersion , currentVersion , StringComparison . InvariantCultureIgnoreCase ) > 0 )
682
686
{
@@ -715,15 +719,13 @@ private static async Task<bool> DownloadAndUpgradeApp(string downloadUrl, string
715
719
716
720
try
717
721
{
718
- // Extract the ZIP
719
722
string tempDirectory = Path . Combine ( Path . GetTempPath ( ) , "appUpdate" ) ;
720
723
if ( Directory . Exists ( tempDirectory ) )
721
724
Directory . Delete ( tempDirectory , true ) ;
722
725
ZipFile . ExtractToDirectory ( tempFile , tempDirectory ) ;
723
726
724
727
// Stop services or processes if necessary
725
728
726
- // Replace files
727
729
foreach ( var file in Directory . GetFiles ( tempDirectory ) )
728
730
{
729
731
string destFile = Path . Combine ( installDirectory , Path . GetFileName ( file ) ) ;
@@ -738,12 +740,9 @@ private static async Task<bool> DownloadAndUpgradeApp(string downloadUrl, string
738
740
Directory . Move ( dir , destDir ) ;
739
741
}
740
742
741
- // Clean up
742
743
File . Delete ( tempFile ) ;
743
744
Directory . Delete ( tempDirectory , true ) ;
744
745
745
- // Restart services or application if necessary
746
-
747
746
return true ;
748
747
}
749
748
catch ( Exception ex )
@@ -790,7 +789,6 @@ private static async Task UpdateNovelFileType(Guid id)
790
789
Logger . Error ( $ "Exception when trying to update novel file type. { ex . Message } ") ;
791
790
}
792
791
}
793
-
794
792
#endregion
795
793
796
794
#region Setup
0 commit comments