allow multiple distributions
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>4.2.12</Version>
|
||||
<Version>4.3.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user