From e7d91567bf0039581906a7e3a505d4120ecfbace Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 18 Mar 2026 11:28:47 -0700 Subject: [PATCH] fix save_vif to compute ExpireAtSec from TTL Go's SaveVolumeInfo always computes ExpireAtSec = now + ttlSeconds when the volume has a TTL. The save_vif path (used by set_read_only and set_writable) was missing this computation, causing .vif files to be written without the correct expiration timestamp for TTL volumes. --- seaweed-volume/src/storage/volume.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/seaweed-volume/src/storage/volume.rs b/seaweed-volume/src/storage/volume.rs index 4e55d06e1..6277181b0 100644 --- a/seaweed-volume/src/storage/volume.rs +++ b/seaweed-volume/src/storage/volume.rs @@ -2185,6 +2185,17 @@ impl Volume { let mut vif = VifVolumeInfo::from_pb(&self.volume_info); vif.read_only = self.no_write_or_delete; + + // Match Go's SaveVolumeInfo: compute ExpireAtSec from TTL + let ttl_seconds = self.super_block.ttl.to_seconds(); + if ttl_seconds > 0 { + let now = SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap_or_default() + .as_secs(); + vif.expire_at_sec = now + ttl_seconds; + } + let content = serde_json::to_string_pretty(&vif) .map_err(|e| VolumeError::Io(io::Error::new(io::ErrorKind::Other, e.to_string())))?; fs::write(&vif_path, content)?;