From a363d573e3c0002bd35b2bdcdd5cd4f033fbd1d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= Date: Fri, 8 May 2026 23:07:15 -0400 Subject: [PATCH] dht: fix persisted permanent values never expiring When values are exported and re-imported, permanent values retain their time_point::max() expiration but lose their permanent flag. This caused them to be stored as non-permanent with an effectively infinite expiration, so they would never expire. Cap the expiration of non-permanent values to created + type.expiration, ensuring that imported permanent values get a finite expiration matching their value type. --- src/dht.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dht.cpp b/src/dht.cpp index 4d43fd8c..273478bc 100644 --- a/src/dht.cpp +++ b/src/dht.cpp @@ -1432,6 +1432,8 @@ Dht::storageStore(const InfoHash& id, created = std::min(created, now); if (expiration == time_point::min()) expiration = permanent ? time_point::max() : created + getType(value->type).expiration; + else if (not permanent) + expiration = std::min(expiration, created + getType(value->type).expiration); if (expiration < now) return false;