Skip to content

Commit

Permalink
Update PacketViewModel.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
JusterZhu committed Jan 7, 2024
1 parent 781d1bb commit 928bea3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/WPF/GeneralUpdate.Packet/ViewModels/PacketViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Text;
using System.Windows;
using Microsoft.WindowsAPICodePack.Dialogs;
using GeneralUpdate.Zip;

namespace GeneralUpdate.Packet.ViewModels
{
Expand Down Expand Up @@ -197,9 +198,15 @@ private async Task BuildPacketCallback()

try
{
// Copy all folders containing drivers in the root directory.
CopyDirectory(DriverDir, TargetPath);

// Build patch package
await DifferentialCore.Instance.Clean(SourcePath, TargetPath, PatchPath, (sender, args) => { },
String2OperationType(CurrentFormat), String2Encoding(CurrentEncoding), PacketName);

await CreateZip();

if (IsPublish)
{
var packetPath = Path.Combine(TargetPath, $"{PacketName}{CurrentFormat}");
Expand Down Expand Up @@ -352,6 +359,16 @@ private void CopyDirectory(string sourceDir, string targetDir)
}
}

private async Task CreateZip()
{
new GeneralZipFactory()
.CreateOperate(OperationType.GZip, packetName, sourcePath, targetPath)
.CreateZip();

var path = Path.Combine(targetPath, packetName);
await ShowMessage("Compression operation", File.Exists(path) ? $"{path} Created successfully." : $"{path} Creation failure!");
}

#endregion Private Methods
}
}

0 comments on commit 928bea3

Please sign in to comment.