@@ -315,46 +315,34 @@ async fn image_download(image_name: &str, output_dir: Option<String>, extract: b
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}" ) ;
320- println ! ( "Target path: {}" , output_path. display( ) ) ;
321- println ! ( "Expected SHA256: {}" , image. sha256) ;
318+ println ! ( "Downloading image: {image_name}" ) ;
322319
323320 // Check if file exists, if so verify SHA256
324321 if output_path. exists ( ) {
325- println ! ( "Local file exists, verifying SHA256..." ) ;
326322 match image_verify_sha256 ( & output_path, image. sha256 ) {
327323 Ok ( true ) => {
328- println ! ( "File verification successful, SHA256 matches, no need to download " ) ;
324+ println ! ( "Image already exists and verified " ) ;
329325 return Ok ( ( ) ) ;
330326 }
331327 Ok ( false ) => {
332- println ! ( "File verification failed, SHA256 does not match, will re-download " ) ;
328+ println ! ( "Existing image verification failed, re-downloading " ) ;
333329 // Remove the invalid file before downloading
334- match fs:: remove_file ( & output_path) {
335- Ok ( _) => println ! ( "Successfully removed invalid file" ) ,
336- Err ( e) => println ! ( "Warning: Failed to remove invalid file: {e}, but will continue with download" ) ,
337- }
330+ let _ = fs:: remove_file ( & output_path) ;
338331 }
339- Err ( e ) => {
340- println ! ( "Error verifying file: {e}, will re-download " ) ;
332+ Err ( _ ) => {
333+ println ! ( "Error verifying existing image, re-downloading " ) ;
341334 // Remove the potentially corrupted file before downloading
342- match fs:: remove_file ( & output_path) {
343- Ok ( _) => println ! ( "Successfully removed potentially corrupted file" ) ,
344- Err ( remove_err) => println ! ( "Warning: Failed to remove potentially corrupted file: {remove_err}, but will continue with download" ) ,
345- }
335+ let _ = fs:: remove_file ( & output_path) ;
346336 }
347337 }
348- } else {
349- println ! ( "Local file does not exist, will start download" ) ;
350338 }
351339
352340 // Ensure target directory exists
353341 if let Some ( parent) = output_path. parent ( ) {
354342 fs:: create_dir_all ( parent) ?;
355343 }
356344
357- println ! ( "Downloading file from {download_url} ..." ) ;
345+ println ! ( "Starting download ..." ) ;
358346
359347 // Use reqwest to download the file
360348 let response = reqwest:: get ( & download_url) . await ?;
@@ -373,35 +361,27 @@ async fn image_download(image_name: &str, output_dir: Option<String>, extract: b
373361 . await ?;
374362 file. write_all ( & bytes) . await ?;
375363
376- println ! ( "Download completed ({} bytes)" , bytes. len( ) ) ;
377364
378365 // Verify downloaded file
379- println ! ( "Verifying SHA256 of downloaded file..." ) ;
380366 match image_verify_sha256 ( & output_path, image. sha256 ) {
381367 Ok ( true ) => {
382- println ! ( "Download completed, file verification successful " ) ;
368+ println ! ( "Download completed and verified successfully " ) ;
383369 }
384370 Ok ( false ) => {
385371 // Remove the invalid downloaded file
386- match fs:: remove_file ( & output_path) {
387- Ok ( _) => println ! ( "Successfully removed invalid downloaded file" ) ,
388- Err ( e) => println ! ( "Warning: Failed to remove invalid downloaded file: {e}" ) ,
389- }
372+ let _ = fs:: remove_file ( & output_path) ;
390373 return Err ( anyhow ! ( "Downloaded file SHA256 verification failed" ) ) ;
391374 }
392375 Err ( e) => {
393376 // Remove the potentially corrupted downloaded file
394- match fs:: remove_file ( & output_path) {
395- Ok ( _) => println ! ( "Successfully removed potentially corrupted downloaded file" ) ,
396- Err ( remove_err) => println ! ( "Warning: Failed to remove potentially corrupted downloaded file: {remove_err}" ) ,
397- }
377+ let _ = fs:: remove_file ( & output_path) ;
398378 return Err ( anyhow ! ( "Error verifying downloaded file: {e}" ) ) ;
399379 }
400380 }
401381
402382 // If extract flag is true, extract the downloaded file
403383 if extract {
404- println ! ( "Extracting downloaded file ..." ) ;
384+ println ! ( "Extracting image ..." ) ;
405385
406386 // Determine extraction output directory
407387 let extract_dir = output_path. parent ( )
@@ -411,8 +391,6 @@ async fn image_download(image_name: &str, output_dir: Option<String>, extract: b
411391 // Ensure extraction directory exists
412392 fs:: create_dir_all ( & extract_dir) ?;
413393
414- println ! ( "Extracting to: {}" , extract_dir. display( ) ) ;
415-
416394 // Use tar command to extract file
417395 let mut child = Command :: new ( "tar" )
418396 . arg ( "-xzf" )
@@ -426,7 +404,6 @@ async fn image_download(image_name: &str, output_dir: Option<String>, extract: b
426404 return Err ( anyhow ! ( "Extraction failed, tar exit code: {status}" ) ) ;
427405 }
428406
429- println ! ( "Extraction completed successfully" ) ;
430407 println ! ( "Image extracted to: {}" , extract_dir. display( ) ) ;
431408 }
432409
@@ -458,22 +435,20 @@ fn image_remove(image_name: &str) -> Result<()> {
458435
459436 // Remove the tar file if it exists
460437 if tar_file. exists ( ) {
461- println ! ( "Removing tar file: {}" , tar_file. display( ) ) ;
462438 fs:: remove_file ( & tar_file) ?;
463439 removed = true ;
464440 }
465441
466442 // Remove the extracted directory if it exists
467443 if extract_dir. exists ( ) {
468- println ! ( "Removing extracted directory: {}" , extract_dir. display( ) ) ;
469444 fs:: remove_dir_all ( & extract_dir) ?;
470445 removed = true ;
471446 }
472447
473448 if !removed {
474449 println ! ( "No files found for image: {image_name}" ) ;
475450 } else {
476- println ! ( "Successfully removed image: {image_name} " ) ;
451+ println ! ( "Image removed successfully " ) ;
477452 }
478453
479454 Ok ( ( ) )
0 commit comments