From b30d272ee6bc5154b2a17a892f1a6cca39022143 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Fri, 8 May 2026 17:37:32 +0200 Subject: [PATCH] Ensure non-corrupting stats writes --- RNS/Utilities/rngit/server.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/RNS/Utilities/rngit/server.py b/RNS/Utilities/rngit/server.py index b52549c1..f1b5faca 100644 --- a/RNS/Utilities/rngit/server.py +++ b/RNS/Utilities/rngit/server.py @@ -1294,7 +1294,9 @@ class ReticulumGitNode(): def __persist_stats(self): with self.stats_lock: try: - with open(self.statspath, "wb") as fh: fh.write(mp.packb(self.stats)) + tmp_path = self.statspath+".tmp" + with open(tmp_path, "wb") as fh: fh.write(mp.packb(self.stats)) + os.rename(tmp_path, self.statspath) except Exception as e: RNS.log(f"Could not write stats file to {self.statspath}: {e}", RNS.LOG_ERROR) def __apply_config(self):