Ensure non-corrupting stats writes

This commit is contained in:
Mark Qvist
2026-05-08 17:37:32 +02:00
parent cc90ac2853
commit b30d272ee6
+3 -1
View File
@@ -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):