Skip to content

Commit 1aa7510

Browse files
committed
fix(files): sort by filename to have a reproducibly walking iterator
The underlaying structure's order is not fixed and may depend on the filesystem implementation. Therefor the iterator needs to be sorted by filename to guarantee a reproducible order of processing input files. One effect of this issue can be observed by having an unreproducible order of posts that have the very same published_date (or none as that falls back to default_date) purely depending on the order the underlaying filesystem serves the files for consumption. This fixes #457
1 parent 4d8bf4d commit 1aa7510

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/cobalt_model/files.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ impl<'a> FilesIterator<'a> {
9191
let walker = WalkDir::new(files.root_dir.as_path())
9292
.min_depth(1)
9393
.follow_links(false)
94+
.sort_by(|a, b| a.file_name().cmp(b.file_name()))
9495
.into_iter()
9596
.filter_entry(move |e| files.includes_entry(e))
9697
.filter_map(|e| e.ok())

0 commit comments

Comments
 (0)