浏览代码

Fixed incompatible.json deserialization

flabbet 4 年之前
父节点
当前提交
1d9ad48a17

+ 0 - 2
PixiEditor.UpdateModule/ReleaseInfo.cs

@@ -24,8 +24,6 @@ namespace PixiEditor.UpdateModule
 
 
         [JsonPropertyName("assets")]
         [JsonPropertyName("assets")]
         public Asset[] Assets { get; set; }
         public Asset[] Assets { get; set; }
-        [JsonPropertyName("target_commitish")]
-        public string TargetCommitish { get; set; }
 
 
         public bool WasDataFetchSuccessful { get; set; } = true;
         public bool WasDataFetchSuccessful { get; set; } = true;
     }
     }

+ 5 - 5
PixiEditor.UpdateModule/UpdateChecker.cs

@@ -10,8 +10,8 @@ namespace PixiEditor.UpdateModule
 {
 {
     public class UpdateChecker
     public class UpdateChecker
     {
     {
-        private const string ReleaseApiUrl = "https://api.github.com/repos/PixiEditor/PixiEditor/releases/latest";
-        private const string IncompatibleFileApiUrl = "https://api.github.com/repos/PixiEditor/PixiEditor/contents/incompatible.json";
+        private const string ReleaseApiUrl = "https://api.github.com/repos/PixiEditor/autoupdate-prod-test/releases/latest";
+        private const string IncompatibleFileApiUrl = "https://raw.githubusercontent.com/PixiEditor/autoupdate-prod-test/{0}/incompatible.json";
 
 
         public UpdateChecker(string currentVersionTag)
         public UpdateChecker(string currentVersionTag)
         {
         {
@@ -61,16 +61,16 @@ namespace PixiEditor.UpdateModule
 
 
         public async Task<bool> IsUpdateCompatible()
         public async Task<bool> IsUpdateCompatible()
         {
         {
-            string[] incompatibleVersions = await GetUpdateIncompatibleVersionsAsync(LatestReleaseInfo.TargetCommitish);
+            string[] incompatibleVersions = await GetUpdateIncompatibleVersionsAsync(LatestReleaseInfo.TagName);
             return IsUpdateCompatible(incompatibleVersions);
             return IsUpdateCompatible(incompatibleVersions);
         }
         }
 
 
-        public async Task<string[]> GetUpdateIncompatibleVersionsAsync(string targetCommitish)
+        public async Task<string[]> GetUpdateIncompatibleVersionsAsync(string tag)
         {
         {
             using (HttpClient client = new HttpClient())
             using (HttpClient client = new HttpClient())
             {
             {
                 client.DefaultRequestHeaders.Add("User-Agent", "PixiEditor");
                 client.DefaultRequestHeaders.Add("User-Agent", "PixiEditor");
-                HttpResponseMessage response = await client.GetAsync(IncompatibleFileApiUrl + $"?ref={targetCommitish}");
+                HttpResponseMessage response = await client.GetAsync(string.Format(IncompatibleFileApiUrl, tag));
                 if (response.StatusCode == HttpStatusCode.OK)
                 if (response.StatusCode == HttpStatusCode.OK)
                 {
                 {
                     string content = await response.Content.ReadAsStringAsync();
                     string content = await response.Content.ReadAsStringAsync();

+ 1 - 1
PixiEditor/ViewModels/SubViewModels/Main/UpdateViewModel.cs

@@ -60,7 +60,7 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
                 if (updateAvailable && updateFileDoesNotExists)
                 if (updateAvailable && updateFileDoesNotExists)
                 {
                 {
                     VersionText = "Downloading update...";
                     VersionText = "Downloading update...";
-                    if (!updateCompatible)
+                    if (updateCompatible)
                     {
                     {
                         await UpdateDownloader.DownloadReleaseZip(UpdateChecker.LatestReleaseInfo);
                         await UpdateDownloader.DownloadReleaseZip(UpdateChecker.LatestReleaseInfo);
                     }
                     }

+ 1 - 0
incompatible.json

@@ -0,0 +1 @@
+[]