From 231b7c9be3a5091041a7dbb0e90d0c303ccbd6eb Mon Sep 17 00:00:00 2001 From: Jared Lunde Date: Fri, 12 Jun 2026 11:08:46 -0700 Subject: [PATCH] fix: saturating prune-cutoff cast, drop stale dead_code allow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - transport.rs: prune cutoff now uses i64::try_from(...).unwrap_or(i64::MAX) instead of a silent 'as i64' wrap — same discipline as the nats.rs max_age conversion. - nats.rs: NatsHandle.client carried a stale #[allow(dead_code)]; the field is read by store_with_config, so the suppression was vestigial. Removed it and pointed the comment at the real reader. Co-Authored-By: Claude Fable 5 --- src/nats.rs | 4 ++-- src/transport.rs | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/nats.rs b/src/nats.rs index 050bd92..192446a 100644 --- a/src/nats.rs +++ b/src/nats.rs @@ -312,8 +312,8 @@ struct NatsHandle { // Held to keep the NATS connection alive for the lifetime of the handle. // The `jetstream` context clones an internal reference, but this field is // the authoritative owner — dropping the handle drops the connection. - // `dead_code` because we never read it directly after construction. - #[allow(dead_code)] + // Also read by `store_with_config`, which clones it out from under the + // handle lock. client: async_nats::Client, jetstream: async_nats::jetstream::Context, } diff --git a/src/transport.rs b/src/transport.rs index dd9fbfd..c42c008 100644 --- a/src/transport.rs +++ b/src/transport.rs @@ -615,7 +615,10 @@ impl ArtifactTransport for ObjectStoreTransport { let cutoff_millis = std::time::SystemTime::now() .checked_sub(grace) .and_then(|t| t.duration_since(std::time::UNIX_EPOCH).ok()) - .map_or(0, |d| d.as_millis() as i64); + // Saturate rather than `as i64`, which would silently wrap a + // >292-million-year value — unreachable for wall-clock millis, but + // the same discipline as the nats.rs max_age conversion. + .map_or(0, |d| i64::try_from(d.as_millis()).unwrap_or(i64::MAX)); let mut deleted = 0usize; let mut listing = self.store.list(Some(&self.payloads_dir(key)));