bugfix: FileExistsError

master
b3yond 2018-01-18 13:40:07 +01:00
parent 99a5c76e24
commit 4d39fd861d
1 changed files with 6 additions and 2 deletions

View File

@ -55,8 +55,12 @@ class RetootBot(object):
def save_last(self):
""" save the last seen toot """
with os.fdopen(os.open('seen_toots.pickle.part', os.O_WRONLY | os.O_EXCL | os.O_CREAT), 'wb') as f:
pickle.dump(self.seen_toots, f)
try:
with os.fdopen(os.open('seen_toots.pickle.part', os.O_WRONLY | os.O_EXCL | os.O_CREAT), 'wb') as f:
pickle.dump(self.seen_toots, f)
except FileExistsError:
with os.fdopen(os.open('seen_toots.pickle.part', os.O_WRONLY), 'wb') as f:
pickle.dump(self.seen_toots, f)
def crawl(self):
"""