allow local folders as packagesource
This commit is contained in:
@@ -108,29 +108,36 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
||||
{
|
||||
RaiseStatusChanged(UpdateStatus.Downloading, UpdateStatusEvent.PreEvent);
|
||||
|
||||
var dirPath = Path.Combine(MyPaths.GetMyAppDataPath(), package.GetHashCode().ToString());
|
||||
var zipPath = Path.Combine(dirPath, "package.zip");
|
||||
var dir = new DirectoryInfo(dirPath);
|
||||
|
||||
try
|
||||
if (package.AddressType == PackageAddressType.Http)
|
||||
{
|
||||
// Ensure existing and empty directory for the Zip File
|
||||
if (dir.Exists)
|
||||
dir.Delete(true);
|
||||
dir.Create();
|
||||
var dirPath = Path.Combine(MyPaths.GetMyAppDataPath(), package.GetHashCode().ToString());
|
||||
var zipPath = Path.Combine(dirPath, "package.zip");
|
||||
var dir = new DirectoryInfo(dirPath);
|
||||
|
||||
// Download zip package
|
||||
using var zipFile = new FileStream(zipPath, FileMode.Create, FileAccess.ReadWrite);
|
||||
using var zipStream = await WebClient.GetStreamAsync(package.Packagelink);
|
||||
await zipStream.CopyToAsync(zipFile);
|
||||
try
|
||||
{
|
||||
// Ensure existing and empty directory for the Zip File
|
||||
if (dir.Exists)
|
||||
dir.Delete(true);
|
||||
dir.Create();
|
||||
|
||||
// Remember path to package directory
|
||||
dicPackagePaths.Add(package, dirPath);
|
||||
// Download zip package
|
||||
using var zipFile = new FileStream(zipPath, FileMode.Create, FileAccess.ReadWrite);
|
||||
using var zipStream = await WebClient.GetStreamAsync(package.Address);
|
||||
await zipStream.CopyToAsync(zipFile);
|
||||
|
||||
// Remember path to package directory
|
||||
dicPackagePaths.Add(package, dirPath);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
else if (package.AddressType == PackageAddressType.Local)
|
||||
dicPackagePaths.Add(package, package.Address);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!RaiseStatusChanged(UpdateStatus.Downloading, UpdateStatusEvent.PostEvent, true))
|
||||
{
|
||||
@@ -154,14 +161,22 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
||||
RaiseStatusChanged(UpdateStatus.Failed);
|
||||
return;
|
||||
}
|
||||
var dataPath = packagePath + ".extracted";
|
||||
var packagePathDir = new DirectoryInfo(packagePath);
|
||||
if (packagePathDir.Exists)
|
||||
string dataPath;
|
||||
if (package.Type == PackageType.Zip)
|
||||
{
|
||||
packagePathDir.Delete(true);
|
||||
Task.Delay(1000);
|
||||
dataPath = packagePath + ".extracted";
|
||||
var packagePathDir = new DirectoryInfo(packagePath);
|
||||
if (packagePathDir.Exists)
|
||||
{
|
||||
packagePathDir.Delete(true);
|
||||
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);
|
||||
|
||||
// Install Package
|
||||
|
||||
Reference in New Issue
Block a user