Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion crates/uffs-mft/src/index/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,15 @@ impl MftIndex {
tracing::debug!("[TRIP] MftIndex::from_parsed_records -> Phase 2: ExtensionIndex::build");
index.extension_index = Some(ExtensionIndex::build(&index));

// 2. Compute tree metrics for directory statistics (Phase 5)
// 2. Sort directory children for deterministic OFFLINE output (Phase 4)
// CRITICAL: OFFLINE path (from_parsed_records) requires sorted children
// for deterministic CSV output order. LIVE paths (to_index.rs) do NOT
// sort to match C++ behavior (reverse MFT parse order).
tracing::debug!("[TRIP] MftIndex::from_parsed_records -> Phase 4: sort_directory_children");
index.sort_directory_children();

// 3. Compute tree metrics for directory statistics (Phase 5)
// Must run AFTER sorting in OFFLINE path for deterministic results.
tracing::debug!("[TRIP] MftIndex::from_parsed_records -> Phase 5: compute_tree_metrics");
index.compute_tree_metrics();

Expand Down
3 changes: 3 additions & 0 deletions crates/uffs-mft/src/index/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ impl MftIndex {
debug!("🔨 Building extension index...");
self.extension_index = Some(ExtensionIndex::build(self));

debug!("🔨 Sorting directory children...");
self.sort_directory_children();

debug!("🔨 Computing tree metrics...");
self.compute_tree_metrics();

Expand Down
4 changes: 4 additions & 0 deletions crates/uffs-mft/src/reader/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,10 @@ impl MftReader {
}
}

// Sort directory children for deterministic output
// CRITICAL for OFFLINE path: ensures consistent ordering across runs
index.sort_directory_children();

// Compute tree metrics
index.compute_tree_metrics();

Expand Down
2 changes: 2 additions & 0 deletions scripts/verify_parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,8 @@ fn regenerate_rust_output(
drive_letter,
"--tz-offset",
&tz_str,
"--format",
"custom", // Match C++ baseline footer format
"--out",
&rust_output.to_string_lossy(),
])
Expand Down
Loading