fix(tvix/store/bin): don't unwrap in case of invalid paths
Instead, return an error, and move the entire check before starting to ingest the data underneath. Change-Id: Idcfba115cb7d599f5fc72a156aaad9d4d4714fcf Reviewed-on: https://cl.tvl.fyi/c/depot/+/10507 Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de>
This commit is contained in:
parent
694ed7ea1a
commit
fa335aaa68
1 changed files with 12 additions and 8 deletions
|
|
@ -261,6 +261,17 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let path_info_service = path_info_service.clone();
|
let path_info_service = path_info_service.clone();
|
||||||
|
|
||||||
async move {
|
async move {
|
||||||
|
// calculate the name
|
||||||
|
let name = path
|
||||||
|
.file_name()
|
||||||
|
.and_then(|file_name| file_name.to_str())
|
||||||
|
.ok_or_else(|| {
|
||||||
|
std::io::Error::new(
|
||||||
|
std::io::ErrorKind::InvalidInput,
|
||||||
|
"path must not be .. and the basename valid unicode",
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
// Ingest the path into blob and directory service.
|
// Ingest the path into blob and directory service.
|
||||||
let root_node = import::ingest_path(
|
let root_node = import::ingest_path(
|
||||||
blob_service.clone(),
|
blob_service.clone(),
|
||||||
|
|
@ -271,15 +282,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
.expect("failed to ingest path");
|
.expect("failed to ingest path");
|
||||||
|
|
||||||
// Ask the PathInfoService for the NAR size and sha256
|
// Ask the PathInfoService for the NAR size and sha256
|
||||||
let root_node_copy = root_node.clone();
|
|
||||||
let (nar_size, nar_sha256) =
|
let (nar_size, nar_sha256) =
|
||||||
path_info_service.calculate_nar(&root_node_copy).await?;
|
path_info_service.calculate_nar(&root_node).await?;
|
||||||
|
|
||||||
let name = path
|
|
||||||
.file_name()
|
|
||||||
.expect("path must not be ..")
|
|
||||||
.to_str()
|
|
||||||
.expect("path must be valid unicode");
|
|
||||||
|
|
||||||
let output_path =
|
let output_path =
|
||||||
store_path::build_nar_based_store_path(&nar_sha256, name);
|
store_path::build_nar_based_store_path(&nar_sha256, name);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue