@@ -74,7 +74,7 @@ def __init__(self, global_constants: constants.Constants,
7474 self .kdk_url : str = ""
7575 self .kdk_url_build : str = ""
7676 self .kdk_url_version : str = ""
77-
77+ self . size = 0
7878 self .kdk_url_expected_size : int = 0
7979
8080 self .kdk_url_is_exactly_match : bool = False
@@ -259,7 +259,12 @@ def _get_latest_kdk(self, host_build: str = None, host_version: str = None) -> N
259259
260260 self .success = True
261261
262-
262+ def convert_size (self , size_str ):
263+ units = {'KB' : 1024 , 'MB' : 1024 ** 2 , 'GB' : 1024 ** 3 , 'TB' : 1024 ** 4 }
264+ for unit , factor in units .items ():
265+ if unit in size_str :
266+ return float (size_str .replace (unit , '' )) * factor
267+ return float (size_str )
263268 def retrieve_download (self , override_path : str = "" ) -> network_handler .DownloadObject :
264269 """
265270 Returns a DownloadObject for the KDK
@@ -283,15 +288,19 @@ def retrieve_download(self, override_path: str = "") -> network_handler.Download
283288 self .error_msg = "Could not retrieve KDK catalog, no KDK to download"
284289 logging .error (self .error_msg )
285290 return None
286-
291+ re = requests .get (self .kdk_url )
292+ json = re .json ()
293+ for i in json :
294+ if i ["build" ]== self .kdk_url_build :
295+ self .size = self .convert_size (i ["fileSize" ])
287296 logging .info (f"Returning DownloadObject for KDK: { Path (self .kdk_url ).name } " )
288297 self .success = True
289298
290299 kdk_download_path = self .constants .kdk_download_path if override_path == "" else Path (override_path )
291300 kdk_plist_path = Path (f"{ kdk_download_path .parent } /{ KDK_INFO_PLIST } " ) if override_path == "" else Path (f"{ Path (override_path ).parent } /{ KDK_INFO_PLIST } " )
292301
293302 self ._generate_kdk_info_plist (kdk_plist_path )
294- return network_handler .DownloadObject (self .kdk_url , kdk_download_path )
303+ return network_handler .DownloadObject (self .kdk_url , kdk_download_path , self . size )
295304
296305
297306 def _generate_kdk_info_plist (self , plist_path : str ) -> None :
0 commit comments