Add Path package source property

This commit is contained in:
2025-11-09 13:39:44 +01:00
parent 8779e306da
commit 6487c54797
4 changed files with 34 additions and 18 deletions

View File

@@ -8,7 +8,7 @@
</PropertyGroup>
<PropertyGroup>
<Version>4.4.3</Version>
<Version>4.4.4</Version>
</PropertyGroup>
<ItemGroup>

View File

@@ -189,18 +189,30 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
// Install Package
RaiseStatusChanged(UpdateStatus.Copying, UpdateStatusEvent.PreEvent);
if (package.UpdateType == UpdateType.Folder)
switch (package.UpdateType)
{
var dataPathDir = Directory.CreateDirectory(dataPath);
var destDir = Directory.CreateDirectory(localInstallPath);
Utils.CopyFiles(dataPathDir, destDir);
}
else if (package.UpdateType == UpdateType.File)
{
if (packageSource.PackageType == PackageType.File)
Utils.CopyFile(new FileInfo(dataPath), new FileInfo(localInstallPath));
else if (Directory.GetFiles(dataPath).FirstOrDefault() is { } firstFile)
Utils.CopyFile(new FileInfo(firstFile), new FileInfo(localInstallPath));
case UpdateType.Folder:
{
var dataPathDir = Directory.CreateDirectory(dataPath);
var destDir = Directory.CreateDirectory(localInstallPath);
Utils.CopyFiles(dataPathDir, destDir);
break;
}
case UpdateType.File:
{
string? srcFilePath = null;
if (packageSource.PackageType == PackageType.File)
srcFilePath = dataPath;
else if (!string.IsNullOrWhiteSpace(packageSource.Address))
srcFilePath = Path.Combine(dataPath, packageSource.Address);
else if (Directory.GetFiles(dataPath).FirstOrDefault() is { } firstFile)
srcFilePath = firstFile;
if (srcFilePath != null)
Utils.CopyFile(new FileInfo(srcFilePath), new FileInfo(localInstallPath));
break;
}
}
RaiseStatusChanged(UpdateStatus.Copying, UpdateStatusEvent.PostEvent);
@@ -220,13 +232,16 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
// Delete Package
RaiseStatusChanged(UpdateStatus.Cleanup, UpdateStatusEvent.PreEvent);
if (packageSource.PackageType == PackageType.Zip)
switch (packageSource.PackageType)
{
File.Delete(packagePath);
Directory.Delete(dataPath, true);
case PackageType.Zip:
File.Delete(packagePath);
Directory.Delete(dataPath, true);
break;
case PackageType.File when packageSource.AddressType == PackageAddressType.Http:
File.Delete(dataPath);
break;
}
else if (packageSource.PackageType == PackageType.File && packageSource.AddressType == PackageAddressType.Http)
File.Delete(dataPath);
RaiseStatusChanged(UpdateStatus.Cleanup, UpdateStatusEvent.PostEvent);
// Finish

View File

@@ -6,6 +6,7 @@ namespace Pilz.Updating;
public class PackageSource(string address)
{
public string Address { get; set; } = address;
public string? Path { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public PackageAddressType AddressType { get; set; }

View File

@@ -8,7 +8,7 @@
</PropertyGroup>
<PropertyGroup>
<Version>4.3.4</Version>
<Version>4.3.5</Version>
</PropertyGroup>
<ItemGroup>