1
0
mirror of https://github.com/instaloader/instaloader.git synced 2024-09-11 16:22:24 +02:00

Fix missing directory error in some rare cases

This commit is contained in:
Alexander Graf 2019-07-27 21:08:29 +02:00
parent 6d5bb1e181
commit 6a3b05762e

View File

@ -246,6 +246,7 @@ class Instaloader:
filename += '.json.xz'
else:
filename += '.json'
os.makedirs(os.path.dirname(filename), exist_ok=True)
save_structure_to_file(structure, filename)
if isinstance(structure, (Post, StoryItem)):
# log 'json ' message when saving Post or StoryItem
@ -374,6 +375,7 @@ class Instaloader:
os.path.getsize(filename) >= int(content_length))):
self.context.log(filename + ' already exists')
return None
os.makedirs(os.path.dirname(filename), exist_ok=True)
self.context.write_raw(profile_pic_bytes if profile_pic_bytes else profile_pic_response, filename)
if date_object:
os.utime(filename, (datetime.now().timestamp(), date_object.timestamp()))