allow local folders as packagesource
This commit is contained in:
@@ -108,6 +108,8 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
|||||||
{
|
{
|
||||||
RaiseStatusChanged(UpdateStatus.Downloading, UpdateStatusEvent.PreEvent);
|
RaiseStatusChanged(UpdateStatus.Downloading, UpdateStatusEvent.PreEvent);
|
||||||
|
|
||||||
|
if (package.AddressType == PackageAddressType.Http)
|
||||||
|
{
|
||||||
var dirPath = Path.Combine(MyPaths.GetMyAppDataPath(), package.GetHashCode().ToString());
|
var dirPath = Path.Combine(MyPaths.GetMyAppDataPath(), package.GetHashCode().ToString());
|
||||||
var zipPath = Path.Combine(dirPath, "package.zip");
|
var zipPath = Path.Combine(dirPath, "package.zip");
|
||||||
var dir = new DirectoryInfo(dirPath);
|
var dir = new DirectoryInfo(dirPath);
|
||||||
@@ -121,7 +123,7 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
|||||||
|
|
||||||
// Download zip package
|
// Download zip package
|
||||||
using var zipFile = new FileStream(zipPath, FileMode.Create, FileAccess.ReadWrite);
|
using var zipFile = new FileStream(zipPath, FileMode.Create, FileAccess.ReadWrite);
|
||||||
using var zipStream = await WebClient.GetStreamAsync(package.Packagelink);
|
using var zipStream = await WebClient.GetStreamAsync(package.Address);
|
||||||
await zipStream.CopyToAsync(zipFile);
|
await zipStream.CopyToAsync(zipFile);
|
||||||
|
|
||||||
// Remember path to package directory
|
// Remember path to package directory
|
||||||
@@ -131,6 +133,11 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (package.AddressType == PackageAddressType.Local)
|
||||||
|
dicPackagePaths.Add(package, package.Address);
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!RaiseStatusChanged(UpdateStatus.Downloading, UpdateStatusEvent.PostEvent, true))
|
if (!RaiseStatusChanged(UpdateStatus.Downloading, UpdateStatusEvent.PostEvent, true))
|
||||||
{
|
{
|
||||||
@@ -154,7 +161,10 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
|||||||
RaiseStatusChanged(UpdateStatus.Failed);
|
RaiseStatusChanged(UpdateStatus.Failed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var dataPath = packagePath + ".extracted";
|
string dataPath;
|
||||||
|
if (package.Type == PackageType.Zip)
|
||||||
|
{
|
||||||
|
dataPath = packagePath + ".extracted";
|
||||||
var packagePathDir = new DirectoryInfo(packagePath);
|
var packagePathDir = new DirectoryInfo(packagePath);
|
||||||
if (packagePathDir.Exists)
|
if (packagePathDir.Exists)
|
||||||
{
|
{
|
||||||
@@ -162,6 +172,11 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
|||||||
Task.Delay(1000);
|
Task.Delay(1000);
|
||||||
}
|
}
|
||||||
ZipFile.ExtractToDirectory(packagePath, dataPath);
|
ZipFile.ExtractToDirectory(packagePath, dataPath);
|
||||||
|
}
|
||||||
|
else if (package.Type == PackageType.Folder)
|
||||||
|
dataPath = packagePath;
|
||||||
|
else
|
||||||
|
throw new NotImplementedException("This PackageType is not defined and not support!");
|
||||||
RaiseStatusChanged(UpdateStatus.Extracting, UpdateStatusEvent.PostEvent);
|
RaiseStatusChanged(UpdateStatus.Extracting, UpdateStatusEvent.PostEvent);
|
||||||
|
|
||||||
// Install Package
|
// Install Package
|
||||||
|
|||||||
7
Pilz.Updating.Client/UpdateMethod.cs
Normal file
7
Pilz.Updating.Client/UpdateMethod.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Pilz.Updating.Client;
|
||||||
|
|
||||||
|
public enum UpdateMethod
|
||||||
|
{
|
||||||
|
Replace,
|
||||||
|
Temp,
|
||||||
|
}
|
||||||
7
Pilz.Updating/PackageAddressType.cs
Normal file
7
Pilz.Updating/PackageAddressType.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Pilz.Updating;
|
||||||
|
|
||||||
|
public enum PackageAddressType
|
||||||
|
{
|
||||||
|
Http,
|
||||||
|
Local,
|
||||||
|
}
|
||||||
7
Pilz.Updating/PackageType.cs
Normal file
7
Pilz.Updating/PackageType.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Pilz.Updating;
|
||||||
|
|
||||||
|
public enum PackageType
|
||||||
|
{
|
||||||
|
Zip,
|
||||||
|
Folder,
|
||||||
|
}
|
||||||
@@ -1,9 +1,16 @@
|
|||||||
namespace Pilz.Updating;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
public class UpdatePackageInfo(AppVersion version, string packagelink)
|
namespace Pilz.Updating;
|
||||||
|
|
||||||
|
public class UpdatePackageInfo(AppVersion version, string address)
|
||||||
{
|
{
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public AppVersion Version { get; set; } = version;
|
public AppVersion Version { get; set; } = version;
|
||||||
public UpdateNotes Notes { get; } = new();
|
public UpdateNotes Notes { get; } = new();
|
||||||
public string Packagelink { get; set; } = packagelink;
|
public string Address { get; set; } = address;
|
||||||
|
public PackageAddressType AddressType { get; set; }
|
||||||
|
public PackageType Type { get; set; }
|
||||||
|
|
||||||
|
[Obsolete, JsonProperty]
|
||||||
|
private string Packagelink => Address;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user