66from .config_data import ConfigData
77from .humble_api .events import Events
88from .humble_api .humble_hash import HumbleHash
9+ from .humble_api .model .trove_order import TroveOrder
910
1011__author__ = "Brian Schkerke"
1112__copyright__ = "Copyright 2016 Brian Schkerke"
@@ -40,6 +41,7 @@ def __init__(self, cd, cds, co, csp, cv):
4041 self .subproduct_name = csp .product_name
4142 self .humble_md5 = cds .md5
4243 self .machine_name = cd .machine_name
44+ self .is_trove = isinstance (co , TroveOrder )
4345
4446 @property
4547 def local_file_size (self ):
@@ -121,7 +123,7 @@ def check_status(self):
121123 self .local_file_size or 0 ))
122124 self .partial_download = True
123125 self .requires_download = True
124- elif not ConfigData .ignore_md5 :
126+ elif not ConfigData .ignore_md5 and not self . is_trove :
125127 if not self .md5_matches :
126128 self .status_message = (
127129 "MD5 of %s doesn't match (expected %s actual %s)." %
@@ -173,7 +175,8 @@ def __download_file(self, web_request, mode, read_bytes=0):
173175 # For a download that's resumed the content-length will be the
174176 # remaining bytes, not the total.
175177 # total_length = int(web_request.headers.get("content-length"))
176- total_length = self .humble_file_size
178+ total_length = self .humble_file_size or int (
179+ web_request .headers .get ("content-length" ))
177180 chunk_size = ConfigData .chunk_size
178181
179182 for chunk in web_request .iter_content (chunk_size = chunk_size ):
@@ -197,22 +200,25 @@ def __create_directory(self):
197200 os .makedirs (full_directory )
198201
199202 def is_valid (self ):
200- if self .humble_file_size is None or self .humble_file_size == 0 :
201- self .status_message = ("Humble file size reported as 0. "
202- "Download is invalid." )
203- return False
204203 if self .download_url is None or len (self .download_url ) == 0 :
205204 self .status_message = ("Humble download URL is an empty string. "
206205 "Download is invalid." )
207206 return False
208- if self .humble_md5 is None or len (self .humble_md5 ) == 0 :
209- self .status_message = ("Humble MD5 is an empty string. "
210- "Download is invalid." )
211- return False
212207 if self .filename is None or len (self .filename ) == 0 :
213208 self .status_message = ("Filename is an empty string. "
214209 "Download is invalid." )
215210 return False
211+ if self .is_trove :
212+ return True
213+ if self .humble_file_size is None or self .humble_file_size == 0 :
214+ self .status_message = ("Humble file size reported as 0. "
215+ "Download is invalid." )
216+ print ("size reported as 0" )
217+ return False
218+ if self .humble_md5 is None or len (self .humble_md5 ) == 0 :
219+ self .status_message = ("Humble MD5 is an empty string. "
220+ "Download is invalid." )
221+ return False
216222
217223 return True
218224
0 commit comments