Add Path package source property
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>4.4.3</Version>
|
||||
<Version>4.4.4</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user