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 <flokli@flokli.de>
Reviewed-by: Connor Brewster <cbrewster@hey.com>
This commit is contained in:
Florian Klink 2024-05-05 11:23:38 +03:00 committed by clbot
parent 281bd46a43
commit 75f2a1f97d

View file

@ -121,15 +121,17 @@ where
}),
};
if entry.path().components().count() == 1 {
break node;
}
let parent = entry
.path()
.parent()
.expect("Tvix bug: got entry with root 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);
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);
}
};
assert!(