Removed excessive comparison of hash. Added message when file cannot be retrieved.
This commit is contained in:
parent
0287d3a132
commit
419fb2b673
@ -110,11 +110,16 @@ class Scraper:
|
|||||||
retries -= 1
|
retries -= 1
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
if retries == 0:
|
||||||
|
print(f"Cannot retrieve {f.download_url}, {filepath}.")
|
||||||
|
return
|
||||||
if is_same_filename:
|
if is_same_filename:
|
||||||
f1_hexdig, f1_dig = self._hash_file(orig_filepath, f.hash_algorithm)
|
_, f1_dig = self._hash_file(orig_filepath, f.hash_algorithm)
|
||||||
f2_hexdig, f2_dig = self._hash_file(filepath, f.hash_algorithm)
|
_, f2_dig = self._hash_file(filepath, f.hash_algorithm)
|
||||||
if f1_hexdig == f2_hexdig or f1_dig == f2_dig:
|
if f1_dig == f2_dig:
|
||||||
remove(filepath)
|
remove(filepath)
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
print("File Not Found", filepath)
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
print("HTTP Error", e.code, e.reason, f.download_url)
|
print("HTTP Error", e.code, e.reason, f.download_url)
|
||||||
if exists(filepath):
|
if exists(filepath):
|
||||||
|
Loading…
Reference in New Issue
Block a user