From a288c7de517c365230a799e83db62177f15ebe17 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 17 Mar 2026 21:40:10 -0700 Subject: [PATCH] Load EC volume version from .vif matching Go's NewEcVolume Go sets ev.Version = needle.Version(volumeInfo.Version) from the .vif file. Rust was always using Version::current() (V3), which would produce wrong needle actual size calculations for volumes created with V1 or V2. --- .../src/storage/erasure_coding/ec_volume.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/seaweed-volume/src/storage/erasure_coding/ec_volume.rs b/seaweed-volume/src/storage/erasure_coding/ec_volume.rs index 18d5f91bf..019f69cef 100644 --- a/seaweed-volume/src/storage/erasure_coding/ec_volume.rs +++ b/seaweed-volume/src/storage/erasure_coding/ec_volume.rs @@ -77,20 +77,25 @@ impl EcVolume { shards.push(None); } - // Read expire_at_sec from .vif if present - let expire_at_sec = { + // Read expire_at_sec and version from .vif if present (matches Go's MaybeLoadVolumeInfo) + let (expire_at_sec, vif_version) = { let base = crate::storage::volume::volume_file_name(dir, collection, volume_id); let vif_path = format!("{}.vif", base); if let Ok(vif_content) = std::fs::read_to_string(&vif_path) { if let Ok(vif_info) = serde_json::from_str::(&vif_content) { - vif_info.expire_at_sec + let ver = if vif_info.version > 0 { + Version(vif_info.version as u8) + } else { + Version::current() + }; + (vif_info.expire_at_sec, ver) } else { - 0 + (0, Version::current()) } } else { - 0 + (0, Version::current()) } }; @@ -99,7 +104,7 @@ impl EcVolume { collection: collection.to_string(), dir: dir.to_string(), dir_idx: dir_idx.to_string(), - version: Version::current(), + version: vif_version, shards, dat_file_size: 0, data_shards,