Catch error with MacOS writing per issue #407
This commit is contained in:
@@ -94,9 +94,13 @@ class RedditDownloader(RedditConnector):
|
|||||||
f'Hard link made linking {destination} to {self.master_hash_list[resource_hash]}'
|
f'Hard link made linking {destination} to {self.master_hash_list[resource_hash]}'
|
||||||
f' in submission {submission.id}')
|
f' in submission {submission.id}')
|
||||||
return
|
return
|
||||||
with open(destination, 'wb') as file:
|
try:
|
||||||
file.write(res.content)
|
with open(destination, 'wb') as file:
|
||||||
logger.debug(f'Written file to {destination}')
|
file.write(res.content)
|
||||||
|
logger.debug(f'Written file to {destination}')
|
||||||
|
except OSError as e:
|
||||||
|
logger.exception(e)
|
||||||
|
logger.error(f'Failed to write file to {destination} in submission {submission.id}: {e}')
|
||||||
creation_time = time.mktime(datetime.fromtimestamp(submission.created_utc).timetuple())
|
creation_time = time.mktime(datetime.fromtimestamp(submission.created_utc).timetuple())
|
||||||
os.utime(destination, (creation_time, creation_time))
|
os.utime(destination, (creation_time, creation_time))
|
||||||
self.master_hash_list[resource_hash] = destination
|
self.master_hash_list[resource_hash] = destination
|
||||||
|
|||||||
Reference in New Issue
Block a user