Skip to content

Commit 67e638d

Browse files
committed
Ignore file size and md5 checks for trove items
1 parent 1d1662e commit 67e638d

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

humble_downloader/actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def batch_download(hapi, game_keys):
7171
key)
7272
item_count_total += len(humble_downloads)
7373
download_size_total += sum(
74-
dl.humble_file_size for dl in humble_downloads)
74+
dl.humble_file_size or 0 for dl in humble_downloads)
7575
logger.display_message(False, "Processing",
7676
"Added %d downloads for order %s"
7777
% (len(humble_downloads), key))

humble_downloader/humble_download.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from .config_data import ConfigData
77
from .humble_api.events import Events
88
from .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

Comments
 (0)