Skip to content

Commit

Permalink
fix: avoid exiting as Tokio needs to manage open threads. Fix typo (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelmmiguel authored Feb 21, 2023
1 parent 6f0168d commit 9451c55
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use data::kv::KV;
use router::Routes;
use std::io::{Error, ErrorKind};
use std::path::PathBuf;
use std::process::exit;
use std::{collections::HashMap, sync::RwLock};
use workers::wasm_io::WasmOutput;

Expand Down Expand Up @@ -225,38 +224,40 @@ async fn main() -> std::io::Result<()> {

// Check the given subcommand
if let Some(Main::Runtimes(sub)) = &args.commands {
let mut run_result = Ok(());

match &sub.runtime_commands {
RuntimesCommands::List(list) => {
if let Err(err) = list.run(sub).await {
println!("❌ There was an error listing the runtimes from the repository");
println!("👉 {err}");
exit(1);
run_result = Err(Error::new(ErrorKind::InvalidData, ""));
}
}
RuntimesCommands::Install(install) => {
if let Err(err) = install.run(&args.path, sub).await {
println!("❌ There was an error installing the runtime from the repository");
println!("👉 {err}");
exit(1);
run_result = Err(Error::new(ErrorKind::InvalidData, ""));
}
}
RuntimesCommands::Uninstall(uninstall) => {
if let Err(err) = uninstall.run(&args.path, sub) {
println!("❌ There was an error uninstalling the runtime");
println!("👉 {err}");
exit(1);
run_result = Err(Error::new(ErrorKind::InvalidData, ""));
}
}
RuntimesCommands::Check(check) => {
if let Err(err) = check.run(&args.path) {
println!("❌ There was an error checking the local runtimes");
println!("👉 {err}");
exit(1);
run_result = Err(Error::new(ErrorKind::InvalidData, ""));
}
}
};

Ok(())
run_result
} else {
// TODO(Angelmmiguel): refactor this into a separate command!
// Initialize the routes
Expand Down
2 changes: 1 addition & 1 deletion src/runtimes/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl Checksum {
pub fn validate(&self, bytes: &[u8]) -> Result<()> {
match self {
Checksum::Sha256 { value } if value == &sha256_digest(bytes) => Ok(()),
_ => Err(anyhow!("The checksums dont not match")),
_ => Err(anyhow!("The checksums don't match")),
}
}
}
Expand Down

0 comments on commit 9451c55

Please sign in to comment.