add single file type
This commit is contained in:
@@ -111,7 +111,7 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
|
||||
if (package.AddressType == PackageAddressType.Http)
|
||||
{
|
||||
var dirPath = Path.Combine(MyPaths.GetMyAppDataPath(), package.GetHashCode().ToString());
|
||||
var zipPath = Path.Combine(dirPath, "package.zip");
|
||||
var zipPath = Path.Combine(dirPath, package.PackageType == PackageType.File ? "app.exe" : "package.zip");
|
||||
var dir = new DirectoryInfo(dirPath);
|
||||
|
||||
try
|
||||
@@ -127,7 +127,7 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
|
||||
await zipStream.CopyToAsync(zipFile);
|
||||
|
||||
// Remember path to package directory
|
||||
dicPackagePaths.Add(package, dirPath);
|
||||
dicPackagePaths.Add(package, zipPath);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -163,7 +163,7 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
|
||||
return;
|
||||
}
|
||||
string dataPath;
|
||||
if (package.Type == PackageType.Zip)
|
||||
if (package.PackageType == PackageType.Zip)
|
||||
{
|
||||
dataPath = packagePath + ".extracted";
|
||||
var packagePathDir = new DirectoryInfo(packagePath);
|
||||
@@ -174,26 +174,31 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
|
||||
}
|
||||
ZipFile.ExtractToDirectory(packagePath, dataPath);
|
||||
}
|
||||
else if (package.Type == PackageType.Folder)
|
||||
dataPath = packagePath;
|
||||
else
|
||||
throw new NotImplementedException("This PackageType is not defined and not support!");
|
||||
dataPath = packagePath;
|
||||
RaiseStatusChanged(UpdateStatus.Extracting, UpdateStatusEvent.PostEvent);
|
||||
|
||||
// Install Package
|
||||
RaiseStatusChanged(UpdateStatus.Copying, UpdateStatusEvent.PreEvent);
|
||||
var dataPathDir = Directory.CreateDirectory(dataPath);
|
||||
var destDir = Directory.CreateDirectory(localInstallPath);
|
||||
Utils.CopyFiles(dataPathDir, destDir);
|
||||
if (package.UpdateType == UpdateType.Folder)
|
||||
{
|
||||
var dataPathDir = Directory.CreateDirectory(dataPath);
|
||||
var destDir = Directory.CreateDirectory(localInstallPath);
|
||||
Utils.CopyFiles(dataPathDir, destDir);
|
||||
}
|
||||
else if (package.UpdateType == UpdateType.File)
|
||||
File.Copy(dataPath, localInstallPath);
|
||||
RaiseStatusChanged(UpdateStatus.Copying, UpdateStatusEvent.PostEvent);
|
||||
|
||||
// Delete Package
|
||||
RaiseStatusChanged(UpdateStatus.Cleanup, UpdateStatusEvent.PreEvent);
|
||||
if (package.Type == PackageType.Zip)
|
||||
if (package.PackageType == PackageType.Zip)
|
||||
{
|
||||
File.Delete(packagePath);
|
||||
Directory.Delete(dataPath, true);
|
||||
}
|
||||
else if (package.PackageType == PackageType.File)
|
||||
File.Delete(dataPath);
|
||||
RaiseStatusChanged(UpdateStatus.Cleanup, UpdateStatusEvent.PostEvent);
|
||||
|
||||
// Finish
|
||||
|
||||
Reference in New Issue
Block a user