From b5288f341ce67a37630315a68adf9a1842922e7e Mon Sep 17 00:00:00 2001 From: b3yond Date: Thu, 18 Jan 2018 13:40:07 +0100 Subject: [PATCH] bugfix: FileExistsError --- retootbot.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/retootbot.py b/retootbot.py index 8caaedb..c39f8cb 100755 --- a/retootbot.py +++ b/retootbot.py @@ -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): """