Skip to content

Commit

Permalink
Improve error when file not found, and avoid unnecessary call to try_…
Browse files Browse the repository at this point in the history
…exists, and fix unnecessary recreation of matched pattern

Signed-off-by: Ludvig Liljenberg <lliljenberg@microsoft.com>
  • Loading branch information
ludfjig committed Nov 12, 2024
1 parent 94512d8 commit 996c8ae
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/hyperlight_host/src/sandbox/uninitialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,16 @@ impl UninitializedSandbox {
host_print_writer: Option<&dyn HostFunction1<String, i32>>,
) -> Result<Self> {
log_build_details();

// If the guest binary is a file make sure it exists

let guest_binary = match guest_binary {
GuestBinary::FilePath(binary_path) => {
let path = Path::new(&binary_path).canonicalize()?;
path.try_exists()?;
let path = Path::new(&binary_path)
.canonicalize()
.map_err(|e| new_error!("GuestBinary not found: '{}': {}", binary_path, e))?;
GuestBinary::FilePath(path.to_str().unwrap().to_string())
}
GuestBinary::Buffer(buffer) => GuestBinary::Buffer(buffer),
buffer @ GuestBinary::Buffer(_) => buffer,
};

let run_opts = sandbox_run_options.unwrap_or_default();
Expand Down

0 comments on commit 996c8ae

Please sign in to comment.