feat(tvix/store/import): make sure entries are sorted

The Directory service does already reject inserting invalid (wrongly
sorted) Directory messages, but our test case didn't provoke it.

Change-Id: I228e201925e8999186659a2d8da0118db184d9ab
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8167
Tested-by: BuildkiteCI
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
This commit is contained in:
Florian Klink 2023-02-27 18:07:16 +01:00 committed by flokli
parent a4d06b68d8
commit 2ef60282b6

View file

@ -200,8 +200,11 @@ pub fn import_path<
let mut directories: HashMap<PathBuf, proto::Directory> = HashMap::default();
// TODO: make sure we traverse in sorted order, or insert to parent_directory in sorted order at least.
for entry in WalkDir::new(p).follow_links(false).contents_first(true) {
for entry in WalkDir::new(p)
.follow_links(false)
.contents_first(true)
.sort_by_file_name()
{
let entry = entry.unwrap();
// process_entry wants an Option<Directory> in case the entry points to a directory.