Skip to content

Commit 9a373e6

Browse files
committed
btdu.state: Fix sharing group linkage for duplicate browser paths
Split the sharing group linking loop into two passes to handle duplicate browser paths correctly: - First pass sets the next pointer for ALL pathData entries, including duplicates, because getNext uses findIndex which may return any matching index - Second pass updates firstSharingGroup only for unique browser paths This prevents incorrect linkage when the same browser path appears multiple times in a sharing group's pathData, which can happen when the same extent is used by the same file multiple times.
1 parent 902bba0 commit 9a373e6

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

source/btdu/state.d

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,17 @@ void populateBrowserPathsFromSharingGroup(
558558
foreach (i, ref path; paths)
559559
{
560560
auto browserPath = group.pathData[i].path;
561+
// Set next pointer to the current head of the list.
562+
// This must be done for ALL pathData entries, even duplicates,
563+
// because getNext uses findIndex which may return any matching index.
561564
group.pathData[i].next = browserPath.firstSharingGroup;
562-
browserPath.firstSharingGroup = group;
565+
}
566+
// Now update firstSharingGroup for each unique browserPath
567+
foreach (i, ref path; paths)
568+
{
569+
auto browserPath = group.pathData[i].path;
570+
if (browserPath.firstSharingGroup != group)
571+
browserPath.firstSharingGroup = group;
563572
}
564573
}
565574
else

0 commit comments

Comments
 (0)