mirror of
https://github.com/markqvist/NomadNet.git
synced 2025-12-24 18:24:22 +01:00
Save peer settings file using write-then-copy
This commit is contained in:
@@ -245,6 +245,7 @@ class NomadNetworkApp:
|
||||
self.peer_settings["served_file_requests"] = 0
|
||||
|
||||
except Exception as e:
|
||||
RNS.logdest = RNS.LOG_STDOUT
|
||||
RNS.log(f"Could not load local peer settings from {self.peersettingspath}", RNS.LOG_ERROR)
|
||||
RNS.log(f"The contained exception was: {e}", RNS.LOG_ERROR)
|
||||
RNS.log(f"This likely means that the peer settings file has become corrupt.", RNS.LOG_ERROR)
|
||||
@@ -560,9 +561,9 @@ class NomadNetworkApp:
|
||||
return self.message_router.get_outbound_propagation_node()
|
||||
|
||||
def save_peer_settings(self):
|
||||
file = open(self.peersettingspath, "wb")
|
||||
file.write(msgpack.packb(self.peer_settings))
|
||||
file.close()
|
||||
tmp_path = f"{self.peersettingspath}.tmp"
|
||||
with open(tmp_path, "wb") as file: file.write(msgpack.packb(self.peer_settings))
|
||||
os.replace(tmp_path, self.peersettingspath)
|
||||
|
||||
def lxmf_delivery(self, message):
|
||||
time_string = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(message.timestamp))
|
||||
|
||||
Reference in New Issue
Block a user