Improved ratchet persist reliability

This commit is contained in:
Mark Qvist 2025-05-06 18:18:05 +02:00
parent 65b1667ae7
commit af46e98865

View file

@ -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)