Improved known destination saving on shared instances
This commit is contained in:
parent
75c3180933
commit
5dad76879c
@ -90,11 +90,27 @@ class Identity:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def save_known_destinations():
|
def save_known_destinations():
|
||||||
RNS.log("Saving known destinations to storage...", RNS.LOG_VERBOSE)
|
try:
|
||||||
file = open(RNS.Reticulum.storagepath+"/known_destinations","wb")
|
storage_known_destinations = {}
|
||||||
umsgpack.dump(Identity.known_destinations, file)
|
if os.path.isfile(RNS.Reticulum.storagepath+"/known_destinations"):
|
||||||
file.close()
|
try:
|
||||||
RNS.log("Done saving known destinations to storage", RNS.LOG_VERBOSE)
|
file = open(RNS.Reticulum.storagepath+"/known_destinations","rb")
|
||||||
|
storage_known_destinations = umsgpack.load(file)
|
||||||
|
file.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
for destination_hash in storage_known_destinations:
|
||||||
|
if not destination_hash in Identity.known_destinations:
|
||||||
|
Identity.known_destinations[destination_hash] = storage_known_destinations[destination_hash]
|
||||||
|
|
||||||
|
RNS.log("Saving known destinations to storage...", RNS.LOG_VERBOSE)
|
||||||
|
file = open(RNS.Reticulum.storagepath+"/known_destinations","wb")
|
||||||
|
umsgpack.dump(Identity.known_destinations, file)
|
||||||
|
file.close()
|
||||||
|
RNS.log("Done saving known destinations to storage", RNS.LOG_VERBOSE)
|
||||||
|
except Exception as e:
|
||||||
|
RNS.log("Error while saving known destinations to disk, the contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load_known_destinations():
|
def load_known_destinations():
|
||||||
@ -107,7 +123,7 @@ class Identity:
|
|||||||
except:
|
except:
|
||||||
RNS.log("Error loading known destinations from disk, file will be recreated on exit", RNS.LOG_ERROR)
|
RNS.log("Error loading known destinations from disk, file will be recreated on exit", RNS.LOG_ERROR)
|
||||||
else:
|
else:
|
||||||
RNS.log("Destinations file does not exist, so no known destinations loaded", RNS.LOG_VERBOSE)
|
RNS.log("Destinations file does not exist, no known destinations loaded", RNS.LOG_VERBOSE)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def full_hash(data):
|
def full_hash(data):
|
||||||
|
Loading…
Reference in New Issue
Block a user