Browse Source

Updated updater schema

flabbet 6 months ago
parent
commit
b281c48e6c

+ 0 - 45
src/PixiEditor.Desktop/Info.plist

@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-    <dict>
-        <key>CFBundleName</key>
-        <string>PixiEditor</string>
-        <key>CFBundleDisplayName</key>
-        <string>PixiEditor</string>
-        <key>CFBundleIdentifier</key>
-        <string>com.pixieditor.macos</string>
-        <key>CFBundleVersion</key>
-        <string>{version-string}</string>
-        <key>CFBundlePackageType</key>
-        <string>APPL</string>
-        <key>CFBundleExecutable</key>
-        <string>PixiEditor</string>
-        <key>CFBundleIconFile</key>
-        <string>PixiEditor.icns</string>
-        <key>CFBundleShortVersionString</key>
-        <string>{version-string}</string>
-        <key>CFBundleSignature</key>
-        <string>????</string>
-        <key>NSPrincipalClass</key>
-        <string>NSApplication</string>
-        <key>NSHighResolutionCapable</key>
-        <key>CFBundleDocumentTypes</key>
-        <array>
-            <dict>
-                <key>CFBundleTypeName</key>
-                <string>Pixi Document</string>
-                <key>CFBundleTypeExtensions</key>
-                <array>
-                    <string>pixi</string>
-                </array>
-                <key>CFBundleTypeIconFile</key>
-                <string>PixiEditor.icns</string>
-                <key>CFBundleTypeRole</key>
-                <string>Editor</string>
-                <key>LSHandlerRank</key>
-                <string>Owner</string>
-            </dict>
-        </array>
-        <true/>
-    </dict>
-</plist>

BIN
src/PixiEditor.Desktop/PixiEditor.icns


+ 19 - 22
src/PixiEditor.UpdateModule/UpdateDownloader.cs

@@ -20,17 +20,15 @@ public static class UpdateDownloader
             throw new FileNotFoundException("No matching update for your system found.");
         }
 
-        using (HttpClient client = new HttpClient())
+        using HttpClient client = new HttpClient();
+        client.DefaultRequestHeaders.Add("User-Agent", "PixiEditor");
+        client.DefaultRequestHeaders.Add("Accept", "application/octet-stream");
+        var response = await client.GetAsync(matchingAsset.Url);
+        if (response.StatusCode == HttpStatusCode.OK)
         {
-            client.DefaultRequestHeaders.Add("User-Agent", "PixiEditor");
-            client.DefaultRequestHeaders.Add("Accept", "application/octet-stream");
-            var response = await client.GetAsync(matchingAsset.Url);
-            if (response.StatusCode == HttpStatusCode.OK)
-            {
-                byte[] bytes = await response.Content.ReadAsByteArrayAsync();
-                CreateTempDirectory();
-                File.WriteAllBytes(Path.Join(DownloadLocation, $"update-{release.TagName}.zip"), bytes);
-            }
+            byte[] bytes = await response.Content.ReadAsByteArrayAsync();
+            CreateTempDirectory();
+            await File.WriteAllBytesAsync(Path.Join(DownloadLocation, $"update-{release.TagName}.zip"), bytes);
         }
     }
 
@@ -43,17 +41,15 @@ public static class UpdateDownloader
             throw new FileNotFoundException("No matching update for your system found.");
         }
 
-        using (HttpClient client = new HttpClient())
+        using HttpClient client = new HttpClient();
+        client.DefaultRequestHeaders.Add("User-Agent", "PixiEditor");
+        client.DefaultRequestHeaders.Add("Accept", "application/octet-stream");
+        var response = await client.GetAsync(matchingAsset.Url);
+        if (response.StatusCode == HttpStatusCode.OK)
         {
-            client.DefaultRequestHeaders.Add("User-Agent", "PixiEditor");
-            client.DefaultRequestHeaders.Add("Accept", "application/octet-stream");
-            var response = await client.GetAsync(matchingAsset.Url);
-            if (response.StatusCode == HttpStatusCode.OK)
-            {
-                byte[] bytes = await response.Content.ReadAsByteArrayAsync();
-                CreateTempDirectory();
-                File.WriteAllBytes(Path.Join(DownloadLocation, $"update-{info.TagName}.exe"), bytes);
-            }
+            byte[] bytes = await response.Content.ReadAsByteArrayAsync();
+            CreateTempDirectory();
+            await File.WriteAllBytesAsync(Path.Join(DownloadLocation, $"update-{info.TagName}.exe"), bytes);
         }
     }
 
@@ -67,8 +63,9 @@ public static class UpdateDownloader
 
     private static Asset? GetMatchingAsset(ReleaseInfo release, string assetType = "zip")
     {
-        string arch = IntPtr.Size == 8 ? "x64" : "x86";
+        string arch = "x64";
+        string os = OperatingSystem.IsWindows() ? "win" : OperatingSystem.IsLinux() ? "linux" : "mac";
         return release.Assets.FirstOrDefault(x => x.ContentType.Contains(assetType)
-                                         && x.Name.Contains(arch));
+                                         && x.Name.Contains(arch) && x.Name.Contains(os));
     }
 }

+ 6 - 1
src/PixiEditor/ViewModels/SubViewModels/UpdateViewModel.cs

@@ -257,7 +257,7 @@ internal class UpdateViewModel : SubViewModel<ViewModelMain>
     [Conditional("UPDATE")]
     private async void ConditionalUPDATE()
     {
-        if (PixiEditorSettings.Update.CheckUpdatesOnStartup.Value)
+        if (PixiEditorSettings.Update.CheckUpdatesOnStartup.Value && OsSupported())
         {
             try
             {
@@ -281,6 +281,11 @@ internal class UpdateViewModel : SubViewModel<ViewModelMain>
         }
     }
     
+    private bool OsSupported()
+    {
+        return IOperatingSystem.Current.IsWindows;
+    }
+    
     private bool UpdateInfoExists()
     {
         return File.Exists(Path.Join(Paths.TempFilesPath, "updateInfo.txt"));