Skip to content

Commit 732795c

Browse files
committed
Cleanup with constants
1 parent c12e8af commit 732795c

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/Core/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ public class Constants
44
{
55
public static string NewestVersion = "last-version";
66
public static string UpgradeDirectory = "_upgrade";
7+
public static string RepoReleaseUrl = "https://api.github.com/repos/blogifierdotnet/Blogifier/releases/latest";
78
}
89
}

src/Core/Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp2.1</TargetFramework>
5-
<Version>2.0.2.4</Version>
5+
<Version>2.0.2.5</Version>
66
</PropertyGroup>
77

88
<ItemGroup>

src/Core/Services/WebService.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)