fix: Avoid exception on non-empty directory

pull/558/head
Raphaël Vinot 2022-12-06 11:00:01 +01:00
parent 884b5cf488
commit 52076925b8
2 changed files with 10 additions and 1 deletions

View File

@ -105,6 +105,11 @@ class RiskIQ():
pdns_info = self.client_dns.get_passive_dns(query=hostname, start=first_seen.isoformat())
if not pdns_info:
try:
url_storage_dir.rmdir()
except OSError:
# Not empty.
pass
return
pdns_info['results'] = sorted(pdns_info['results'], key=lambda k: k['lastSeen'], reverse=True)
with riskiq_file.open('w') as _f:

View File

@ -79,7 +79,11 @@ class URLhaus():
if (not url_information
or ('query_status' in url_information
and url_information['query_status'] == 'no_results')):
url_storage_dir.rmdir()
try:
url_storage_dir.rmdir()
except OSError:
# Not empty.
pass
return
with uh_file.open('w') as _f: