Compare commits

..

No commits in common. "ecdef3dcecfb64a61eb5d8c5a59905e1f0c8cc03" and "75194f31a53179e5384ab982ff14e857b70fd915" have entirely different histories.

8 changed files with 20 additions and 52 deletions

View File

@ -4,8 +4,8 @@
<TargetFramework>net8.0</TargetFramework>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<Nullable>enable</Nullable>
<AssemblyVersion>2.12.0</AssemblyVersion>
<FileVersion>2.12.0</FileVersion>
<AssemblyVersion>2.11.0</AssemblyVersion>
<FileVersion>2.11.0</FileVersion>
</PropertyGroup>
<ItemGroup>
<AvaloniaResource Include="Assets\**" />

View File

@ -4,8 +4,8 @@
<TargetFramework>net8.0</TargetFramework>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<Nullable>enable</Nullable>
<AssemblyVersion>2.12.0</AssemblyVersion>
<FileVersion>2.12.0</FileVersion>
<AssemblyVersion>2.11.0</AssemblyVersion>
<FileVersion>2.11.0</FileVersion>
</PropertyGroup>
<ItemGroup>
@ -27,7 +27,7 @@
</ItemGroup>
<ItemGroup>
<None Remove="Resources\7z.dll" />
<EmbeddedResource Include="Resources\7za.exe" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.11" />

Binary file not shown.

View File

@ -16,7 +16,6 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using PatcherUtils.Model;
namespace PatchGenerator.ViewModels
{
@ -141,19 +140,12 @@ namespace PatchGenerator.ViewModels
System.Threading.Thread.Sleep(2000);
PatchItemCollection.Add(new PatchItem("Zipping patcher ..."));
PatchItemCollection.Add(new PatchItem("Kicking off 7zip ..."));
ProgressMessage = "Zipping patcher";
LazyOperations.StartZipProcess(generationInfo.PatchName.FromCwd(), $"{generationInfo.PatchName}.zip".FromCwd());
IndeterminateProgress = false;
var progress = new Progress<int>(p =>
{
PatchPercent = p;
});
LazyOperations.CompressDirectory(generationInfo.PatchName.FromCwd(), $"{generationInfo.PatchName}.7z".FromCwd(), progress);
PatchItemCollection.Add(new PatchItem("Done"));
}

View File

@ -1,9 +1,7 @@
using System;
using PatcherUtils.Model;
using PatcherUtils.Model;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using Aki.Common.Utils;
using SevenZip;
namespace PatcherUtils
{
@ -20,12 +18,12 @@ namespace PatcherUtils
/// </summary>
public static string PatchFolder = "Aki_Patches";
private static string SevenZDll = "7z.dll";
private static string SevenZExe = "7za.exe";
/// <summary>
/// The path to the 7za.exe file in the <see cref="TempDir"/>
/// </summary>
public static string SevenZDllPath = $"{TempDir}\\{SevenZDll}";
public static string SevenZExePath = $"{TempDir}\\{SevenZExe}";
private static string PatcherClient = "PatchClient.exe";
/// <summary>
@ -81,9 +79,9 @@ namespace PatcherUtils
{
switch (resource)
{
case string a when a.EndsWith(SevenZDll):
case string a when a.EndsWith(SevenZExe):
{
StreamResourceOut(assembly, resource, SevenZDllPath);
StreamResourceOut(assembly, resource, SevenZExePath);
break;
}
case string a when a.EndsWith(PatcherClient):
@ -100,34 +98,17 @@ namespace PatcherUtils
}
}
public static void CompressDirectory(string SourceDirectoryPath, string DestinationFilePath, IProgress<int> progress)
public static void StartZipProcess(string SourcePath, string DestinationPath)
{
var outputFile = new FileInfo(DestinationFilePath);
SevenZipBase.SetLibraryPath(SevenZDllPath);
var compressor = new SevenZipCompressor()
ProcessStartInfo procInfo = new ProcessStartInfo()
{
ArchiveFormat = OutArchiveFormat.SevenZip,
CompressionMethod = CompressionMethod.Lzma2,
CompressionLevel = CompressionLevel.Normal
FileName = SevenZExePath,
Arguments = $"a -mm=LZMA {DestinationPath} {SourcePath}"
};
compressor.Compressing += (_, args) =>
{
progress.Report(args.PercentDone);
};
Process.Start(procInfo);
using var outputStream = outputFile.OpenWrite();
compressor.CompressDirectory(SourceDirectoryPath, outputStream);
outputFile.Refresh();
// failed to compress data
if (!outputFile.Exists || outputFile.Length == 0)
{
Logger.LogError("Failed to compress patcher");
}
PatchLogger.LogInfo($"Zip process started");
}
/// <summary>

View File

@ -11,7 +11,6 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\7z.dll" />
<EmbeddedResource Include="Resources\xdelta3.exe" />
</ItemGroup>
@ -21,8 +20,4 @@
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Squid-Box.SevenZipSharp" Version="1.6.1.23" />
</ItemGroup>
</Project>