Switch patch apply to use XDeltaSharp #21

Merged
waffle.lord merged 1 commits from :feat-xdeltasharp into main 2024-06-25 08:54:59 -04:00
2 changed files with 21 additions and 27 deletions

View File

@ -9,7 +9,7 @@ using System.Linq;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using PatcherUtils.Helpers; using PleOps.XdeltaSharp.Decoder;
namespace PatcherUtils namespace PatcherUtils
{ {
@ -114,19 +114,19 @@ namespace PatcherUtils
{ {
string decodedPath = SourceFilePath + ".decoded"; string decodedPath = SourceFilePath + ".decoded";
var xdeltaArgs = $"-d {(debugOutput ? "-v -v" : "")} -f -s"; try
var xdeltaHelper =
new XdeltaProcessHelper(xdeltaArgs, SourceFilePath, DeltaFilePath, decodedPath, debugOutput);
if (!xdeltaHelper.Run())
{ {
return (false, "something went wrong during the xdelta3 process"); using var inputFile = new FileStream(SourceFilePath, FileMode.Open);
using var patchFile = new FileStream(DeltaFilePath, FileMode.Open);
using var decodedFile = new FileStream(decodedPath, FileMode.Create);
using var decoder = new Decoder(inputFile, patchFile, decodedFile);
decoder.Run();
} }
catch (Exception ex)
if (File.Exists(decodedPath))
{ {
PatchLogger.LogInfo($"File delta decoded: {SourceFilePath}"); PatchLogger.LogException(ex);
return (false, ex.Message);
}
try try
{ {
@ -140,13 +140,6 @@ namespace PatcherUtils
return (false, ex.Message); return (false, ex.Message);
} }
} }
else
{
string error = $"Failed to decode file delta: {SourceFilePath}";
PatchLogger.LogError(error);
return (false, error);
}
}
/// <summary> /// <summary>
/// Create a .delta file using xdelta /// Create a .delta file using xdelta

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
@ -22,6 +22,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="PleOps.XdeltaSharp" Version="1.3.0" />
<PackageReference Include="Squid-Box.SevenZipSharp" Version="1.6.2.24" /> <PackageReference Include="Squid-Box.SevenZipSharp" Version="1.6.2.24" />
</ItemGroup> </ItemGroup>