From 0de169836e0b7503ac1bde5202b5397b7888f6e2 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Fri, 29 May 2026 07:53:29 +0200 Subject: [PATCH] Improved cleanup of stale known destinations --- RNS/Identity.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/RNS/Identity.py b/RNS/Identity.py index e519abad..4c86bc15 100644 --- a/RNS/Identity.py +++ b/RNS/Identity.py @@ -316,6 +316,7 @@ class Identity: no_path = 0 retained = 0 never_used = 0 + ratchetdir = RNS.Reticulum.storagepath+"/ratchets" with Identity.known_destinations_lock: destination_hashes = list(Identity.known_destinations.keys()) for destination_hash in destination_hashes: @@ -359,6 +360,12 @@ class Identity: Identity.known_destinations.pop(destination_hash) removed += 1 + try: + hexhash = RNS.hexrep(destination_hash, delimit=False) + ratchet_path = f"{ratchetdir}/{hexhash}" + if os.path.isfile(ratchet_path): os.unlink(ratchet_path) + except Exception as e: RNS.log(f"Could not clean stale ratchets for {RNS.prettyhexrep(destination_hash)}: {e}", RNS.LOG_WARNING) + # RNS.log(f"Total destinations: {total}, stale: {len(stale)}, removed: {removed}, no path: {no_path}, never used: {never_used}, with path: {total-no_path}, used: {total-never_used}, retained: {retained}. Completed in {RNS.prettyshorttime(time.time()-st)}", RNS.LOG_WARNING) # TODO: Remove if not RNS.Transport.owner.is_connected_to_shared_instance: Identity.save_known_destinations(recombine=False)