Add Path package source property
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>4.4.3</Version>
|
<Version>4.4.4</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -189,18 +189,30 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
|
|||||||
|
|
||||||
// Install Package
|
// Install Package
|
||||||
RaiseStatusChanged(UpdateStatus.Copying, UpdateStatusEvent.PreEvent);
|
RaiseStatusChanged(UpdateStatus.Copying, UpdateStatusEvent.PreEvent);
|
||||||
if (package.UpdateType == UpdateType.Folder)
|
switch (package.UpdateType)
|
||||||
|
{
|
||||||
|
case UpdateType.Folder:
|
||||||
{
|
{
|
||||||
var dataPathDir = Directory.CreateDirectory(dataPath);
|
var dataPathDir = Directory.CreateDirectory(dataPath);
|
||||||
var destDir = Directory.CreateDirectory(localInstallPath);
|
var destDir = Directory.CreateDirectory(localInstallPath);
|
||||||
Utils.CopyFiles(dataPathDir, destDir);
|
Utils.CopyFiles(dataPathDir, destDir);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (package.UpdateType == UpdateType.File)
|
case UpdateType.File:
|
||||||
{
|
{
|
||||||
|
string? srcFilePath = null;
|
||||||
|
|
||||||
if (packageSource.PackageType == PackageType.File)
|
if (packageSource.PackageType == PackageType.File)
|
||||||
Utils.CopyFile(new FileInfo(dataPath), new FileInfo(localInstallPath));
|
srcFilePath = dataPath;
|
||||||
|
else if (!string.IsNullOrWhiteSpace(packageSource.Address))
|
||||||
|
srcFilePath = Path.Combine(dataPath, packageSource.Address);
|
||||||
else if (Directory.GetFiles(dataPath).FirstOrDefault() is { } firstFile)
|
else if (Directory.GetFiles(dataPath).FirstOrDefault() is { } firstFile)
|
||||||
Utils.CopyFile(new FileInfo(firstFile), new FileInfo(localInstallPath));
|
srcFilePath = firstFile;
|
||||||
|
|
||||||
|
if (srcFilePath != null)
|
||||||
|
Utils.CopyFile(new FileInfo(srcFilePath), new FileInfo(localInstallPath));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
RaiseStatusChanged(UpdateStatus.Copying, UpdateStatusEvent.PostEvent);
|
RaiseStatusChanged(UpdateStatus.Copying, UpdateStatusEvent.PostEvent);
|
||||||
|
|
||||||
@@ -220,13 +232,16 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
|
|||||||
|
|
||||||
// Delete Package
|
// Delete Package
|
||||||
RaiseStatusChanged(UpdateStatus.Cleanup, UpdateStatusEvent.PreEvent);
|
RaiseStatusChanged(UpdateStatus.Cleanup, UpdateStatusEvent.PreEvent);
|
||||||
if (packageSource.PackageType == PackageType.Zip)
|
switch (packageSource.PackageType)
|
||||||
{
|
{
|
||||||
|
case PackageType.Zip:
|
||||||
File.Delete(packagePath);
|
File.Delete(packagePath);
|
||||||
Directory.Delete(dataPath, true);
|
Directory.Delete(dataPath, true);
|
||||||
}
|
break;
|
||||||
else if (packageSource.PackageType == PackageType.File && packageSource.AddressType == PackageAddressType.Http)
|
case PackageType.File when packageSource.AddressType == PackageAddressType.Http:
|
||||||
File.Delete(dataPath);
|
File.Delete(dataPath);
|
||||||
|
break;
|
||||||
|
}
|
||||||
RaiseStatusChanged(UpdateStatus.Cleanup, UpdateStatusEvent.PostEvent);
|
RaiseStatusChanged(UpdateStatus.Cleanup, UpdateStatusEvent.PostEvent);
|
||||||
|
|
||||||
// Finish
|
// Finish
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace Pilz.Updating;
|
|||||||
public class PackageSource(string address)
|
public class PackageSource(string address)
|
||||||
{
|
{
|
||||||
public string Address { get; set; } = address;
|
public string Address { get; set; } = address;
|
||||||
|
public string? Path { get; set; }
|
||||||
|
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
public PackageAddressType AddressType { get; set; }
|
public PackageAddressType AddressType { get; set; }
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>4.3.4</Version>
|
<Version>4.3.5</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user