mirror of
https://github.com/markqvist/NomadNet.git
synced 2026-12-03 21:30:04 -05:00
Save peer settings file using write-then-copy
This commit is contained in:
parent
a2e6a06a35
commit
5253cccfa7
1 changed files with 4 additions and 3 deletions
|
|
@ -245,6 +245,7 @@ class NomadNetworkApp:
|
||||||
self.peer_settings["served_file_requests"] = 0
|
self.peer_settings["served_file_requests"] = 0
|
||||||
|
|
||||||
except Exception as e:
|
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"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"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)
|
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()
|
return self.message_router.get_outbound_propagation_node()
|
||||||
|
|
||||||
def save_peer_settings(self):
|
def save_peer_settings(self):
|
||||||
file = open(self.peersettingspath, "wb")
|
tmp_path = f"{self.peersettingspath}.tmp"
|
||||||
file.write(msgpack.packb(self.peer_settings))
|
with open(tmp_path, "wb") as file: file.write(msgpack.packb(self.peer_settings))
|
||||||
file.close()
|
os.replace(tmp_path, self.peersettingspath)
|
||||||
|
|
||||||
def lxmf_delivery(self, message):
|
def lxmf_delivery(self, message):
|
||||||
time_string = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(message.timestamp))
|
time_string = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(message.timestamp))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue