diff --git a/Pilz.Updating.Client/Pilz.Updating.Client.csproj b/Pilz.Updating.Client/Pilz.Updating.Client.csproj
index b31c7b8..8d936ff 100644
--- a/Pilz.Updating.Client/Pilz.Updating.Client.csproj
+++ b/Pilz.Updating.Client/Pilz.Updating.Client.csproj
@@ -7,7 +7,7 @@
- 4.2.12
+ 4.3.0
diff --git a/Pilz.Updating.Client/UpdateClient.cs b/Pilz.Updating.Client/UpdateClient.cs
index 5206de7..5c6eb95 100644
--- a/Pilz.Updating.Client/UpdateClient.cs
+++ b/Pilz.Updating.Client/UpdateClient.cs
@@ -25,6 +25,7 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
public bool InstallAsAdmin { get; set; }
public bool UIDarkMode { get; set; }
public bool HasUpdates => UpdatePackageInfo != null;
+ public string? Distro { get; set; }
// E v e n t M e t h o d s
@@ -111,10 +112,11 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
{
RaiseStatusChanged(UpdateStatus.Downloading, UpdateStatusEvent.PreEvent);
- if (package.AddressType == PackageAddressType.Http)
+ var packageSource = package.GetSource(Distro);
+ if (packageSource.AddressType == PackageAddressType.Http)
{
var dirPath = Path.Combine(MyPaths.GetMyAppDataPath(), package.GetHashCode().ToString());
- var zipPath = Path.Combine(dirPath, package.PackageType == PackageType.File ? "app.exe" : "package.zip");
+ var zipPath = Path.Combine(dirPath, packageSource.PackageType == PackageType.File ? "app.exe" : "package.zip");
var dir = new DirectoryInfo(dirPath);
try
@@ -126,7 +128,7 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
// Download zip package
using var zipFile = new FileStream(zipPath, FileMode.Create, FileAccess.ReadWrite);
- using var zipStream = await WebClient.GetStreamAsync(package.GetAddress());
+ using var zipStream = await WebClient.GetStreamAsync(package.GetAddress(Distro));
await zipStream.CopyToAsync(zipFile);
// Remember path to package directory
@@ -137,8 +139,8 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
return false;
}
}
- else if (package.AddressType == PackageAddressType.Local)
- dicPackagePaths.Add(package, package.GetAddress());
+ else if (packageSource.AddressType == PackageAddressType.Local)
+ dicPackagePaths.Add(package, package.GetAddress(Distro));
else
return false;
@@ -166,7 +168,8 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
return false;
}
string dataPath;
- if (package.PackageType == PackageType.Zip)
+ var packageSource = package.GetSource(Distro);
+ if (packageSource.PackageType == PackageType.Zip)
{
dataPath = packagePath + ".extracted";
var packagePathDir = new DirectoryInfo(packagePath);
@@ -195,12 +198,12 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
// Delete Package
RaiseStatusChanged(UpdateStatus.Cleanup, UpdateStatusEvent.PreEvent);
- if (package.PackageType == PackageType.Zip)
+ if (packageSource.PackageType == PackageType.Zip)
{
File.Delete(packagePath);
Directory.Delete(dataPath, true);
}
- else if (package.PackageType == PackageType.File && package.AddressType == PackageAddressType.Http)
+ else if (packageSource.PackageType == PackageType.File && packageSource.AddressType == PackageAddressType.Http)
File.Delete(dataPath);
RaiseStatusChanged(UpdateStatus.Cleanup, UpdateStatusEvent.PostEvent);
diff --git a/Pilz.Updating/PackageSource.cs b/Pilz.Updating/PackageSource.cs
new file mode 100644
index 0000000..e7b4fbd
--- /dev/null
+++ b/Pilz.Updating/PackageSource.cs
@@ -0,0 +1,15 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+
+namespace Pilz.Updating;
+
+public class PackageSource(string address)
+{
+ public string Address { get; set; } = address;
+
+ [JsonConverter(typeof(StringEnumConverter))]
+ public PackageAddressType AddressType { get; set; }
+
+ [JsonConverter(typeof(StringEnumConverter))]
+ public PackageType PackageType { get; set; }
+}
diff --git a/Pilz.Updating/Pilz.Updating.csproj b/Pilz.Updating/Pilz.Updating.csproj
index bd1ec11..8fe47e6 100644
--- a/Pilz.Updating/Pilz.Updating.csproj
+++ b/Pilz.Updating/Pilz.Updating.csproj
@@ -7,7 +7,7 @@
- 4.2.5
+ 4.3.0
diff --git a/Pilz.Updating/UpdatePackageInfo.cs b/Pilz.Updating/UpdatePackageInfo.cs
index 7603c85..2d41a2f 100644
--- a/Pilz.Updating/UpdatePackageInfo.cs
+++ b/Pilz.Updating/UpdatePackageInfo.cs
@@ -4,7 +4,7 @@ using Pilz.Json;
namespace Pilz.Updating;
-public class UpdatePackageInfo(AppVersion version, string address)
+public class UpdatePackageInfo(AppVersion version)
{
public string? Name { get; set; }
@@ -13,25 +13,23 @@ public class UpdatePackageInfo(AppVersion version, string address)
public UpdateNotes Notes { get; } = new();
- public string Address { get; set; } = address;
-
public string? ExePath { get; set; }
- [JsonConverter(typeof(StringEnumConverter))]
- public PackageAddressType AddressType { get; set; }
-
- [JsonConverter(typeof(StringEnumConverter))]
- public PackageType PackageType { get; set; }
+ public Dictionary Packages = [];
[JsonConverter(typeof(StringEnumConverter))]
public UpdateType UpdateType { get; set; }
- [Obsolete, JsonProperty]
- private string Packagelink => GetAddress();
-
- public string GetAddress()
+ public PackageSource GetSource(string? distro)
{
- return Address
+ if (distro == null || !Packages.TryGetValue(distro, out var definition))
+ definition = Packages.Values.FirstOrDefault();
+ return definition ?? throw new KeyNotFoundException("No package definition found!");
+ }
+
+ public string GetAddress(string? distro)
+ {
+ return GetSource(distro).Address
.Replace("{appversion}", Version.ToString())
.Replace("{version}", Version.Version.ToString())
.Replace("{channelstr}", Version.Channel.ToString())