From 2ef60282b61a61496e642021f0ab8eab7569bbaa Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Mon, 27 Feb 2023 18:07:16 +0100 Subject: 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 --- tvix/store/src/import.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tvix') diff --git a/tvix/store/src/import.rs b/tvix/store/src/import.rs index d2abb292fcce..e71798a6eb4c 100644 --- a/tvix/store/src/import.rs +++ b/tvix/store/src/import.rs @@ -200,8 +200,11 @@ pub fn import_path< let mut directories: HashMap = 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 in case the entry points to a directory. -- cgit 1.4.1