Fix bug where folder is created too late
This commit is contained in:
parent
72b2e30e90
commit
faa3c20713
1 changed files with 1 additions and 1 deletions
|
@ -343,6 +343,7 @@ class RedditDownloader:
|
||||||
f'Failed to download resource from {res.url} with downloader {downloader_class.__name__}')
|
f'Failed to download resource from {res.url} with downloader {downloader_class.__name__}')
|
||||||
return
|
return
|
||||||
resource_hash = res.hash.hexdigest()
|
resource_hash = res.hash.hexdigest()
|
||||||
|
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||||
if resource_hash in self.master_hash_list:
|
if resource_hash in self.master_hash_list:
|
||||||
if self.args.no_dupes:
|
if self.args.no_dupes:
|
||||||
logger.warning(f'Resource from "{res.url}" and hash "{resource_hash}" downloaded elsewhere')
|
logger.warning(f'Resource from "{res.url}" and hash "{resource_hash}" downloaded elsewhere')
|
||||||
|
@ -352,7 +353,6 @@ class RedditDownloader:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
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]}')
|
||||||
return
|
return
|
||||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
|
||||||
with open(destination, 'wb') as file:
|
with open(destination, 'wb') as file:
|
||||||
file.write(res.content)
|
file.write(res.content)
|
||||||
logger.debug(f'Written file to {destination}')
|
logger.debug(f'Written file to {destination}')
|
||||||
|
|
Loading…
Reference in a new issue