@@ -27,7 +27,7 @@ use std::process::Command;
2727use std:: fs;
2828use std:: env;
2929use std:: io:: Read ;
30- use tokio:: fs:: File ;
30+ // use tokio::fs::File; // Unused import
3131use tokio:: io:: AsyncWriteExt ;
3232
3333/// Base URL for downloading images
@@ -233,7 +233,7 @@ fn image_verify_sha256(file_path: &Path, expected_sha256: &str) -> Result<bool>
233233 }
234234
235235 let result = hasher. finalize ( ) ;
236- let actual_sha256 = format ! ( "{:x}" , result ) ;
236+ let actual_sha256 = format ! ( "{result :x}" ) ;
237237
238238 Ok ( actual_sha256 == expected_sha256)
239239}
@@ -290,33 +290,33 @@ fn image_list() -> Result<()> {
290290/// ```
291291async fn image_download ( image_name : & str , output_dir : Option < String > , extract : bool ) -> Result < ( ) > {
292292 let image = Image :: find_by_name ( image_name)
293- . ok_or_else ( || anyhow ! ( "Image not found: {}. Use 'xtask image ls' to view available images" , image_name ) ) ?;
293+ . ok_or_else ( || anyhow ! ( "Image not found: {image_name }. Use 'xtask image ls' to view available images" ) ) ?;
294294
295295 let output_path = match output_dir {
296296 Some ( dir) => {
297297 // Check if it's an absolute path
298298 let path = Path :: new ( & dir) ;
299299 if path. is_absolute ( ) {
300300 // If it's an absolute path, use it directly
301- path. join ( format ! ( "{}.tar.gz" , image_name ) )
301+ path. join ( format ! ( "{image_name }.tar.gz" ) )
302302 } else {
303303 // If it's a relative path, base on current working directory
304304 let current_dir = std:: env:: current_dir ( ) ?;
305- current_dir. join ( path) . join ( format ! ( "{}.tar.gz" , image_name ) )
305+ current_dir. join ( path) . join ( format ! ( "{image_name }.tar.gz" ) )
306306 }
307307 }
308308 None => {
309309 // If not specified, use system temporary directory
310310 let temp_dir = env:: temp_dir ( ) ;
311- temp_dir. join ( "axvisor" ) . join ( format ! ( "{}.tar.gz" , image_name ) )
311+ temp_dir. join ( "axvisor" ) . join ( format ! ( "{image_name }.tar.gz" ) )
312312 }
313313 } ;
314314
315315 // Build download URL
316316 let download_url = format ! ( "{}{}.tar.gz" , IMAGE_URL_BASE , image. name) ;
317317
318- println ! ( "Checking image: {}" , image_name ) ;
319- println ! ( "Download URL: {}" , download_url ) ;
318+ println ! ( "Checking image: {image_name}" ) ;
319+ println ! ( "Download URL: {download_url}" ) ;
320320 println ! ( "Target path: {}" , output_path. display( ) ) ;
321321 println ! ( "Expected SHA256: {}" , image. sha256) ;
322322
@@ -333,15 +333,15 @@ async fn image_download(image_name: &str, output_dir: Option<String>, extract: b
333333 // Remove the invalid file before downloading
334334 match fs:: remove_file ( & output_path) {
335335 Ok ( _) => println ! ( "Successfully removed invalid file" ) ,
336- Err ( e) => println ! ( "Warning: Failed to remove invalid file: {}, but will continue with download" , e ) ,
336+ Err ( e) => println ! ( "Warning: Failed to remove invalid file: {e }, but will continue with download" ) ,
337337 }
338338 }
339339 Err ( e) => {
340- println ! ( "Error verifying file: {}, will re-download" , e ) ;
340+ println ! ( "Error verifying file: {e }, will re-download" ) ;
341341 // Remove the potentially corrupted file before downloading
342342 match fs:: remove_file ( & output_path) {
343343 Ok ( _) => println ! ( "Successfully removed potentially corrupted file" ) ,
344- Err ( remove_err) => println ! ( "Warning: Failed to remove potentially corrupted file: {}, but will continue with download" , remove_err ) ,
344+ Err ( remove_err) => println ! ( "Warning: Failed to remove potentially corrupted file: {remove_err }, but will continue with download" ) ,
345345 }
346346 }
347347 }
@@ -354,7 +354,7 @@ async fn image_download(image_name: &str, output_dir: Option<String>, extract: b
354354 fs:: create_dir_all ( parent) ?;
355355 }
356356
357- println ! ( "Downloading file from {}..." , download_url ) ;
357+ println ! ( "Downloading file from {download_url }..." ) ;
358358
359359 // Use reqwest to download the file
360360 let response = reqwest:: get ( & download_url) . await ?;
@@ -385,17 +385,17 @@ async fn image_download(image_name: &str, output_dir: Option<String>, extract: b
385385 // Remove the invalid downloaded file
386386 match fs:: remove_file ( & output_path) {
387387 Ok ( _) => println ! ( "Successfully removed invalid downloaded file" ) ,
388- Err ( e) => println ! ( "Warning: Failed to remove invalid downloaded file: {}" , e ) ,
388+ Err ( e) => println ! ( "Warning: Failed to remove invalid downloaded file: {e}" ) ,
389389 }
390390 return Err ( anyhow ! ( "Downloaded file SHA256 verification failed" ) ) ;
391391 }
392392 Err ( e) => {
393393 // Remove the potentially corrupted downloaded file
394394 match fs:: remove_file ( & output_path) {
395395 Ok ( _) => println ! ( "Successfully removed potentially corrupted downloaded file" ) ,
396- Err ( remove_err) => println ! ( "Warning: Failed to remove potentially corrupted downloaded file: {}" , remove_err ) ,
396+ Err ( remove_err) => println ! ( "Warning: Failed to remove potentially corrupted downloaded file: {remove_err}" ) ,
397397 }
398- return Err ( anyhow ! ( "Error verifying downloaded file: {}" , e ) ) ;
398+ return Err ( anyhow ! ( "Error verifying downloaded file: {e}" ) ) ;
399399 }
400400 }
401401
@@ -423,7 +423,7 @@ async fn image_download(image_name: &str, output_dir: Option<String>, extract: b
423423
424424 let status = child. wait ( ) ?;
425425 if !status. success ( ) {
426- return Err ( anyhow ! ( "Extraction failed, tar exit code: {}" , status ) ) ;
426+ return Err ( anyhow ! ( "Extraction failed, tar exit code: {status}" ) ) ;
427427 }
428428
429429 println ! ( "Extraction completed successfully" ) ;
@@ -448,10 +448,10 @@ async fn image_download(image_name: &str, output_dir: Option<String>, extract: b
448448fn image_remove ( image_name : & str ) -> Result < ( ) > {
449449 // Check if the image name is valid by looking it up
450450 let _image = Image :: find_by_name ( image_name)
451- . ok_or_else ( || anyhow ! ( "Image not found: {}. Use 'xtask image ls' to view available images" , image_name ) ) ?;
451+ . ok_or_else ( || anyhow ! ( "Image not found: {image_name }. Use 'xtask image ls' to view available images" ) ) ?;
452452
453453 let temp_dir = env:: temp_dir ( ) . join ( "axvisor" ) ;
454- let tar_file = temp_dir. join ( format ! ( "{}.tar.gz" , image_name ) ) ;
454+ let tar_file = temp_dir. join ( format ! ( "{image_name }.tar.gz" ) ) ;
455455 let extract_dir = temp_dir. join ( image_name) ;
456456
457457 let mut removed = false ;
@@ -471,9 +471,9 @@ fn image_remove(image_name: &str) -> Result<()> {
471471 }
472472
473473 if !removed {
474- println ! ( "No files found for image: {}" , image_name ) ;
474+ println ! ( "No files found for image: {image_name}" ) ;
475475 } else {
476- println ! ( "Successfully removed image: {}" , image_name ) ;
476+ println ! ( "Successfully removed image: {image_name}" ) ;
477477 }
478478
479479 Ok ( ( ) )
0 commit comments