@@ -15,7 +15,6 @@ public class WebService : IWebService
1515 {
1616 IDataService _db ;
1717 static HttpClient client = new HttpClient ( ) ;
18- static string _repoUrl = "https://api.github.com/repos/rxtur/Sandbox/releases/latest" ; // "https://api.github.com/repos/blogifierdotnet/Blogifier/releases/latest";
1918
2019 public WebService ( IDataService db )
2120 {
@@ -31,7 +30,7 @@ public WebService(IDataService db)
3130 public async Task < string > CheckForLatestRelease ( )
3231 {
3332 string result = "" ;
34- HttpResponseMessage response = await client . GetAsync ( _repoUrl ) ;
33+ HttpResponseMessage response = await client . GetAsync ( Constants . RepoReleaseUrl ) ;
3534
3635 if ( response . IsSuccessStatusCode )
3736 {
@@ -67,16 +66,15 @@ public async Task<string> CheckForLatestRelease()
6766
6867 public async Task < string > DownloadLatestRelease ( )
6968 {
70- var uloadDir = "_upgrade" ;
7169 var msg = "" ;
7270 try
7371 {
74- HttpResponseMessage response = await client . GetAsync ( _repoUrl ) ;
72+ HttpResponseMessage response = await client . GetAsync ( Constants . RepoReleaseUrl ) ;
7573 if ( response . IsSuccessStatusCode )
7674 {
7775 var repo = await response . Content . ReadAsAsync < Data . Github . Repository > ( ) ;
7876 var zipUrl = repo . assets [ 0 ] . browser_download_url ;
79- var zipPath = $ "{ uloadDir } { Path . DirectorySeparatorChar . ToString ( ) } { repo . tag_name } .zip";
77+ var zipPath = $ "{ Constants . UpgradeDirectory } { Path . DirectorySeparatorChar . ToString ( ) } { repo . tag_name } .zip";
8078
8179 using ( var client = new HttpClient ( ) )
8280 {
@@ -86,12 +84,12 @@ public async Task<string> DownloadLatestRelease()
8684 {
8785 var zipBites = await result . Content . ReadAsByteArrayAsync ( ) ;
8886
89- if ( ! Directory . Exists ( uloadDir ) )
90- Directory . CreateDirectory ( uloadDir ) ;
87+ if ( ! Directory . Exists ( Constants . UpgradeDirectory ) )
88+ Directory . CreateDirectory ( Constants . UpgradeDirectory ) ;
9189
9290 File . WriteAllBytes ( zipPath , zipBites ) ;
9391
94- ZipFile . ExtractToDirectory ( zipPath , uloadDir ) ;
92+ ZipFile . ExtractToDirectory ( zipPath , Constants . UpgradeDirectory ) ;
9593 }
9694 }
9795 }
0 commit comments