Skip to content

Commit 8e784c2

Browse files
NeWbY100claude
andcommitted
fix: detect RAR block-payload differences in Compare tab
Thread IHexDataSource through IFileCompareService.Compare / FileCompareService.Compare so the parent app can pass the left/right MemoryMappedDataSource into FileComparer. FileCompareViewModel forwards both sources during RefreshComparison and calls the new HasBlockDifferences in ApplyNodeHighlighting so file/service blocks whose data payloads differ are now flagged [DIFF] in the structure tree. UpdateStatus checks LeftDiffRanges / RightDiffRanges and reports "Byte-level differences detected in current hex view..." when the structural compare returns zero diffs but the byte-level hex diff has non-empty ranges, so the status bar can no longer disagree with the red highlights painted in the hex view. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b62a808 commit 8e784c2

5 files changed

Lines changed: 55 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,29 @@ All notable changes to ReScene.NET are documented here.
44
Releases follow [SemVer](https://semver.org/) and this file follows
55
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66

7+
## [1.2.4] — 2026-05-10
8+
9+
### Fixed
10+
11+
- Compare tab no longer reports two RAR files as identical when only
12+
their block payload bytes differ. `FileComparer.CompareDetailedBlocks`
13+
now byte-compares each block's data region (`StartOffset + HeaderSize`
14+
through `+ DataSize`) in 64 KB chunks when both sides supply an
15+
`IHexDataSource`, surfacing a `Block Data` property difference and
16+
marking the affected file/service block as `[DIFF]` in the structure
17+
tree. Previously the comparator only inspected parsed RAR header
18+
fields, so two archives with identical metadata (filename, packed
19+
size, file CRC32, timestamp) but different compressed payloads — the
20+
exact case produced when reconstructing — slipped through as
21+
"identical."
22+
- The status bar can no longer disagree with the hex-view byte diff:
23+
when the structural compare finds zero differences but the byte-level
24+
hex diff reports differing ranges, the status now reads "Byte-level
25+
differences detected in current hex view but no structural
26+
differences found." instead of "Files are identical."
27+
28+
[1.2.4]: https://github.com/NeWbY100/ReScene.NET/releases/tag/v1.2.4
29+
730
## [1.2.3] — 2026-05-08
831

932
### Added

ReScene.Lib

ReScene.NET/Services/FileCompareService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using ReScene.Core.Comparison;
2+
using ReScene.Hex;
23
using ReScene.RAR;
34
using ReScene.SRS;
45

@@ -42,5 +43,6 @@ public class FileCompareService : IFileCompareService
4243

4344
/// <inheritdoc />
4445
public CompareResult Compare(object? leftData, object? rightData,
45-
List<RARDetailedBlock>? leftBlocks = null, List<RARDetailedBlock>? rightBlocks = null) => FileComparer.Compare(leftData, rightData, leftBlocks, rightBlocks);
46+
List<RARDetailedBlock>? leftBlocks = null, List<RARDetailedBlock>? rightBlocks = null,
47+
IHexDataSource? leftSource = null, IHexDataSource? rightSource = null) => FileComparer.Compare(leftData, rightData, leftBlocks, rightBlocks, leftSource, rightSource);
4648
}

ReScene.NET/Services/IFileCompareService.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using ReScene.Core.Comparison;
2+
using ReScene.Hex;
23
using ReScene.RAR;
34

45
namespace ReScene.NET.Services;
@@ -45,9 +46,16 @@ public interface IFileCompareService
4546
/// <param name="rightBlocks">
4647
/// Optional detailed RAR blocks for the right file.
4748
/// </param>
49+
/// <param name="leftSource">
50+
/// Optional byte-level data source for the left file, used to compare block payloads.
51+
/// </param>
52+
/// <param name="rightSource">
53+
/// Optional byte-level data source for the right file, used to compare block payloads.
54+
/// </param>
4855
/// <returns>
4956
/// A <see cref="CompareResult"/> describing all differences found.
5057
/// </returns>
5158
public CompareResult Compare(object? leftData, object? rightData,
52-
List<RARDetailedBlock>? leftBlocks = null, List<RARDetailedBlock>? rightBlocks = null);
59+
List<RARDetailedBlock>? leftBlocks = null, List<RARDetailedBlock>? rightBlocks = null,
60+
IHexDataSource? leftSource = null, IHexDataSource? rightSource = null);
5361
}

ReScene.NET/ViewModels/FileCompareViewModel.cs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,8 @@ private void RefreshComparison()
432432
if (_leftData is not null && _rightData is not null)
433433
{
434434
_compareResult = _compareService.Compare(_leftData, _rightData,
435-
_leftDetailedBlocks, _rightDetailedBlocks);
435+
_leftDetailedBlocks, _rightDetailedBlocks,
436+
_leftFileSource, _rightFileSource);
436437
ApplyComparisonHighlighting();
437438
UpdateStatus();
438439
}
@@ -466,10 +467,21 @@ private void UpdateStatus()
466467

467468
if (totalDiffs == 0)
468469
{
469-
StatusMessage = "Files are identical.";
470-
DiffSummary = "No differences found - files are identical.";
471-
HasDiffSummary = true;
472-
FilesIdentical = true;
470+
int byteDiffRanges = (LeftDiffRanges?.Count ?? 0) + (RightDiffRanges?.Count ?? 0);
471+
if (byteDiffRanges > 0)
472+
{
473+
StatusMessage = "Byte-level differences detected in current hex view but no structural differences found.";
474+
DiffSummary = "Byte-level differences detected in current hex view.";
475+
HasDiffSummary = true;
476+
FilesIdentical = false;
477+
}
478+
else
479+
{
480+
StatusMessage = "Files are identical.";
481+
DiffSummary = "No differences found - files are identical.";
482+
HasDiffSummary = true;
483+
FilesIdentical = true;
484+
}
473485
}
474486
else
475487
{
@@ -1199,7 +1211,8 @@ private void ApplyNodeHighlighting(TreeNodeViewModel node, HashSet<string> remov
11991211
{
12001212
RARDetailedBlock? otherBlock = otherBlocks.FirstOrDefault(b =>
12011213
b.BlockType == block.BlockType && b.ItemName == block.ItemName);
1202-
if (otherBlock is not null && FileComparer.HasFieldDifferences(block, otherBlock))
1214+
if (otherBlock is not null
1215+
&& FileComparer.HasBlockDifferences(block, otherBlock, _leftFileSource, _rightFileSource))
12031216
{
12041217
node.Text = $"{GetBaseNodeText(node.Text)} [DIFF]";
12051218
node.IsDifferent = true;

0 commit comments

Comments
 (0)