Switch patch apply to use XDeltaSharp #21
@ -9,7 +9,7 @@ using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using PatcherUtils.Helpers;
|
||||
using PleOps.XdeltaSharp.Decoder;
|
||||
|
||||
namespace PatcherUtils
|
||||
{
|
||||
@ -114,37 +114,30 @@ namespace PatcherUtils
|
||||
{
|
||||
string decodedPath = SourceFilePath + ".decoded";
|
||||
|
||||
var xdeltaArgs = $"-d {(debugOutput ? "-v -v" : "")} -f -s";
|
||||
|
||||
var xdeltaHelper =
|
||||
new XdeltaProcessHelper(xdeltaArgs, SourceFilePath, DeltaFilePath, decodedPath, debugOutput);
|
||||
|
||||
if (!xdeltaHelper.Run())
|
||||
try
|
||||
{
|
||||
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}");
|
||||
|
||||
try
|
||||
{
|
||||
File.Move(decodedPath, SourceFilePath, true);
|
||||
PatchLogger.LogInfo($"Delta applied: {DeltaFilePath}");
|
||||
return (true, "");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
PatchLogger.LogException(ex);
|
||||
return (false, ex.Message);
|
||||
}
|
||||
File.Move(decodedPath, SourceFilePath, true);
|
||||
PatchLogger.LogInfo($"Delta applied: {DeltaFilePath}");
|
||||
return (true, "");
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
string error = $"Failed to decode file delta: {SourceFilePath}";
|
||||
PatchLogger.LogError(error);
|
||||
return (false, error);
|
||||
PatchLogger.LogException(ex);
|
||||
return (false, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
@ -22,6 +22,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="PleOps.XdeltaSharp" Version="1.3.0" />
|
||||
<PackageReference Include="Squid-Box.SevenZipSharp" Version="1.6.2.24" />
|
||||
</ItemGroup>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user