Compare commits

...

2 Commits

Author SHA1 Message Date
e2c1e9831d Merge pull request 'Switch patch apply to use XDeltaSharp' (#21) from DrakiaXYZ/Patcher:feat-xdeltasharp into main
Reviewed-on: #21
2024-06-25 12:54:58 +00:00
DrakiaXYZ
a22fccd42d Switch patch apply to use XDeltaSharp
- This resolves the persistent `-1073741819` error some users receive during patching
- XDeltaSharp doesn't support creating deltas, so patch creation still depends on xdelta3.exe
2024-06-24 21:36:06 -07: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,37 +114,30 @@ 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)
{
PatchLogger.LogException(ex);
return (false, ex.Message);
} }
if (File.Exists(decodedPath)) try
{ {
PatchLogger.LogInfo($"File delta decoded: {SourceFilePath}"); File.Move(decodedPath, SourceFilePath, true);
PatchLogger.LogInfo($"Delta applied: {DeltaFilePath}");
try return (true, "");
{
File.Move(decodedPath, SourceFilePath, true);
PatchLogger.LogInfo($"Delta applied: {DeltaFilePath}");
return (true, "");
}
catch (Exception ex)
{
PatchLogger.LogException(ex);
return (false, ex.Message);
}
} }
else catch (Exception ex)
{ {
string error = $"Failed to decode file delta: {SourceFilePath}"; PatchLogger.LogException(ex);
PatchLogger.LogError(error); return (false, ex.Message);
return (false, error);
} }
} }

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>