From 75f2a1f97d80469d7a179970377b373e89d7a28a Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sun, 5 May 2024 11:23:38 +0300 Subject: fix(tvix/castore/import): deal with entry.path() not having a parent We got away with not properly dealing with this for the archive case, where everything is contained inside a toplevel dir, but NARs can encode a single file/symlink. Properly break if the IngestionEntry path has the ROOT as parent, and only create filling directories in the other case. Change-Id: Ib378d0d1040de7c3fe310912a0b0488c55afee83 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11590 Tested-by: BuildkiteCI Autosubmit: flokli Reviewed-by: Connor Brewster --- tvix/castore/src/import/mod.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'tvix/castore/src') diff --git a/tvix/castore/src/import/mod.rs b/tvix/castore/src/import/mod.rs index 6c69d04f3026..87e289911300 100644 --- a/tvix/castore/src/import/mod.rs +++ b/tvix/castore/src/import/mod.rs @@ -121,15 +121,17 @@ where }), }; - if entry.path().components().count() == 1 { + let parent = entry + .path() + .parent() + .expect("Tvix bug: got entry with root node"); + + if parent == crate::Path::ROOT { break node; + } else { + // record node in parent directory, creating a new [Directory] if not there yet. + directories.entry(parent.to_owned()).or_default().add(node); } - - // record node in parent directory, creating a new [Directory] if not there yet. - directories - .entry(entry.path().parent().unwrap().to_owned()) - .or_default() - .add(node); }; assert!( -- cgit 1.4.1