fix(tvix/castore/import): don't unwrap entry
If the path specified doesn't exist, construct a proper error instead of panicking. Part of b/344. Change-Id: Id5c6a91248b0a387f3e8f138f8e686e402009e8f Reviewed-on: https://cl.tvl.fyi/c/depot/+/10330 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI
This commit is contained in:
parent
afd09c3290
commit
81ef26ba3f
1 changed files with 8 additions and 2 deletions
|
@ -155,7 +155,7 @@ pub async fn ingest_path<P: AsRef<Path> + Debug>(
|
||||||
|
|
||||||
let mut directory_putter = directory_service.put_multiple_start();
|
let mut directory_putter = directory_service.put_multiple_start();
|
||||||
|
|
||||||
for entry in WalkDir::new(p)
|
for entry in WalkDir::new(p.as_ref())
|
||||||
.follow_links(false)
|
.follow_links(false)
|
||||||
.follow_root_links(false)
|
.follow_root_links(false)
|
||||||
// We need to process a directory's children before processing
|
// We need to process a directory's children before processing
|
||||||
|
@ -164,7 +164,13 @@ pub async fn ingest_path<P: AsRef<Path> + Debug>(
|
||||||
.contents_first(true)
|
.contents_first(true)
|
||||||
.sort_by_file_name()
|
.sort_by_file_name()
|
||||||
{
|
{
|
||||||
let entry = entry.unwrap();
|
// Entry could be a NotFound, if the root path specified does not exist.
|
||||||
|
let entry = entry.map_err(|e| {
|
||||||
|
Error::UnableToOpen(
|
||||||
|
PathBuf::from(p.as_ref()),
|
||||||
|
e.into_io_error().expect("walkdir err must be some"),
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
// process_entry wants an Option<Directory> in case the entry points to a directory.
|
// process_entry wants an Option<Directory> in case the entry points to a directory.
|
||||||
// make sure to provide it.
|
// make sure to provide it.
|
||||||
|
|
Loading…
Reference in a new issue