@@ -84,9 +84,9 @@ def retrieve_image_metadata(image_path: str) -> dict:
8484 ].decode ("utf-8" )
8585 logger .info (f"Metadata retrieved from image { image_path .split ('/' )[- 1 ]} ." )
8686 return metadata_dict
87- except zipfile .BadZipFile :
87+ except zipfile .BadZipFile as e :
8888 logger .error ("Selected image is not a zip file." )
89- return dict
89+ raise e
9090 except (FileNotFoundError , KeyError ):
9191 logger .error (
9292 f"Metadata file { metapath } not found in { image_path .split ('/' )[- 1 ]} ."
@@ -132,8 +132,8 @@ def image_works_with_device(
132132 Returns:
133133 CheckResult object containing the compatibility status and a message.
134134 """
135- metadata = retrieve_image_metadata (image_path )
136135 try :
136+ metadata = retrieve_image_metadata (image_path )
137137 supported_devices = metadata ["pre-device" ].split ("," )
138138 logger .info (f"Image works with the following device(s): { supported_devices } " )
139139 if any (code in supported_devices for code in supported_device_codes ):
@@ -148,6 +148,11 @@ def image_works_with_device(
148148 CompatibilityStatus .INCOMPATIBLE ,
149149 f"Image file { image_path .split ('/' )[- 1 ]} is not supported by device code." ,
150150 )
151+ except zipfile .BadZipFile :
152+ return CheckResult (
153+ CompatibilityStatus .INCOMPATIBLE ,
154+ f"Selected image { image_path .split ('/' )[- 1 ]} is not a zip file." ,
155+ )
151156 except KeyError :
152157 logger .error (
153158 f"Could not determine supported devices for { image_path .split ('/' )[- 1 ]} ."
0 commit comments