Skip to content

Commit

Permalink
Merge pull request #945 from SeanTAllen/patch-2
Browse files Browse the repository at this point in the history
Remove non-determinism in hard link handling
  • Loading branch information
dcantah authored Feb 11, 2021
2 parents 7bf6ec3 + 45104de commit 122ec5a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions ext4/internal/compactext4/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,13 @@ func (w *Writer) writeDirectory(dir, parent *inode) error {
children = append(children, name)
}
sort.Slice(children, func(i, j int) bool {
return dir.Children[children[i]].Number < dir.Children[children[j]].Number
left_num := dir.Children[children[i]].Number
right_num := dir.Children[children[j]].Number

if left_num == right_num {
return children[i] < children[j]
}
return left_num < right_num
})

for _, name := range children {
Expand Down Expand Up @@ -952,7 +958,13 @@ func (w *Writer) writeDirectoryRecursive(dir, parent *inode) error {
children = append(children, name)
}
sort.Slice(children, func(i, j int) bool {
return dir.Children[children[i]].Number < dir.Children[children[j]].Number
left_num := dir.Children[children[i]].Number
right_num := dir.Children[children[j]].Number

if left_num == right_num {
return children[i] < children[j]
}
return left_num < right_num
})

for _, name := range children {
Expand Down

0 comments on commit 122ec5a

Please sign in to comment.