Improve file injection error handling
All checks were successful
lint/clippy Checking for common mistakes and opportunities for code improvement
build/linux Build for the target platform: linux
build/msvc Build for the target platform: msvc

This commit is contained in:
Lucas Schwiderski 2025-05-30 15:48:47 +02:00
parent 5f5f6f1539
commit 98e0ea70e5
Signed by: lucas
GPG key ID: AA12679AAA6DF4D8

View file

@ -202,15 +202,13 @@ pub(crate) async fn run(ctx: sdk::Context, matches: &ArgMatches) -> Result<()> {
let bundle_name = Bundle::get_name_from_path(&ctx, bundle_path); let bundle_name = Bundle::get_name_from_path(&ctx, bundle_path);
let mut bundle = { let mut bundle = {
let binary = fs::read(bundle_path).await?; fs::read(bundle_path)
Bundle::from_binary(&ctx, bundle_name.clone(), binary) .await
.map_err(From::from)
.and_then(|binary| Bundle::from_binary(&ctx, bundle_name.clone(), binary))
.wrap_err_with(|| format!("Failed to open bundle '{}'", bundle_path.display()))? .wrap_err_with(|| format!("Failed to open bundle '{}'", bundle_path.display()))?
}; };
if op == "copy" {
unimplemented!("Implement copying a file from one bundle to the other.");
}
let output_bundle = match op { let output_bundle = match op {
"replace" => { "replace" => {
let Some(file) = bundle let Some(file) = bundle
@ -280,6 +278,9 @@ pub(crate) async fn run(ctx: sdk::Context, matches: &ArgMatches) -> Result<()> {
"add" => { "add" => {
unimplemented!("Implement adding a new file to the bundle."); unimplemented!("Implement adding a new file to the bundle.");
} }
"copy" => {
unimplemented!("Implement copying a file from one bundle to the other.");
}
_ => unreachable!("no other operations exist"), _ => unreachable!("no other operations exist"),
}; };