From af46e98865768530c9c490f3eb6b2255ccb4b7de Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Tue, 6 May 2025 18:18:05 +0200 Subject: [PATCH] Improved ratchet persist reliability --- RNS/Destination.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RNS/Destination.py b/RNS/Destination.py index 00b7f68..a3f3a3e 100755 --- a/RNS/Destination.py +++ b/RNS/Destination.py @@ -216,9 +216,10 @@ class Destination: ratchets_file = open(temp_write_path, "wb") ratchets_file.write(umsgpack.packb(persisted_data)) ratchets_file.close() - os.unlink(self.ratchets_path) + if os.path.isfile(self.ratchets_path): os.unlink(self.ratchets_path) os.rename(temp_write_path, self.ratchets_path) except Exception as e: + RNS.trace_exception(e) self.ratchets = None self.ratchets_path = None raise OSError("Could not write ratchet file contents for "+str(self)+". The contained exception was: "+str(e), RNS.LOG_ERROR)