From 44ee42ba8a71e78068133ca2248ec234bf73729f Mon Sep 17 00:00:00 2001 From: Solderpunk Date: Mon, 8 Jun 2020 21:52:28 +0200 Subject: [PATCH] Check that a file exists before trying to delete it. Rare errors can cause code paths leading to attempted double deletion. --- av98.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/av98.py b/av98.py index bd8b52a..3ae4aae 100755 --- a/av98.py +++ b/av98.py @@ -535,7 +535,7 @@ Slow internet connection? Use 'set timeout' to be more patient.""") # Save the result in a temporary file ## Delete old file - if self.tmp_filename: + if self.tmp_filename and os.path.exists(self.tmp_filename): os.unlink(self.tmp_filename) ## Set file mode if mime.startswith("text/"): @@ -1491,9 +1491,9 @@ current gemini browsing session.""" self.db_conn.commit() self.db_conn.close() # Clean up after ourself - if self.tmp_filename: + if self.tmp_filename and os.path.exists(self.tmp_filename): os.unlink(self.tmp_filename) - if self.idx_filename: + if self.idx_filename and os.path.exists(self.idx_filename): os.unlink(self.idx_filename) for cert in self.transient_certs_created: for ext in (".crt", ".key"):