From cfdb10d1ed22c45afd7bd3b2d62b799cb4a53bd5 Mon Sep 17 00:00:00 2001 From: Muriel Paraire <72733662+MurielParaire@users.noreply.github.com> Date: Fri, 3 May 2024 19:15:47 +0200 Subject: [PATCH] fix(vmm): cleanup code Signed-off-by: Muriel Paraire <72733662+MurielParaire@users.noreply.github.com> --- src/vmm/src/grpc/server.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/vmm/src/grpc/server.rs b/src/vmm/src/grpc/server.rs index fdb0995..3113e72 100644 --- a/src/vmm/src/grpc/server.rs +++ b/src/vmm/src/grpc/server.rs @@ -52,11 +52,10 @@ impl VmmService { curr_dir: &OsStr, ) -> std::result::Result { // define initramfs file placement - let initramfs_entire_file_path = - curr_dir.to_str().unwrap().to_owned() + &format!("/tools/rootfs/{}.img", language); + let initramfs_entire_file_path = &format!("{:?}/tools/rootfs/{language}.img", curr_dir); // set image name - let image = format!("{}:alpine", language); + let image = format!("{language}:alpine"); // check if an initramfs already exists let rootfs_exists = Path::new(&initramfs_entire_file_path) @@ -84,7 +83,7 @@ impl VmmService { vec![ "./tools/rootfs/mkrootfs.sh", &image, - agent_file_name.to_str().unwrap(), + &format!("{:?}", agent_file_name), &initramfs_entire_file_path, ], ) @@ -117,7 +116,7 @@ impl VmmService { args: Vec<&str>, ) -> std::result::Result { // define file path - let entire_path = curr_dir.to_str().unwrap().to_owned() + end_path; + let entire_path = &format!("{:?}/tools/rootfs/{end_path}.img", curr_dir); // Check if the file is on the system, else build it let exists = Path::new(&entire_path) @@ -125,6 +124,7 @@ impl VmmService { .map_err(VmmErrors::VmmBuildEnvironment)?; if !exists { + // we know that the filepath is valid and has more than 1 / in it so we can unwrap info!( "File {:?} not found, building it", &entire_path.split('/').last().unwrap()