Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

defaulting file ttl to volume ttl

Chris Luc2960c7a861d
diff --git a/weed/storage/needle/volume_ttl.go b/weed/storage/needle/volume_ttl.go
index 0b4c9579b3..4a169870d6 100644
--- a/weed/storage/needle/volume_ttl.go
+++ b/weed/storage/needle/volume_ttl.go
@@ -48,6 +48,9 @@ func ReadTTL(ttlString string) (*TTL, error) {
// read stored bytes to a ttl
func LoadTTLFromBytes(input []byte) (t *TTL) {
+ if input[0] == 0 && input[1] == 0 {
+ return EMPTY_TTL
+ }
return &TTL{Count: input[0], Unit: input[1]}
}
diff --git a/weed/storage/volume_read_write.go b/weed/storage/volume_read_write.go
index bd268c1a62..93ce1eab9c 100644
--- a/weed/storage/volume_read_write.go
+++ b/weed/storage/volume_read_write.go
@@ -91,6 +91,11 @@ func (v *Volume) writeNeedle(n *needle.Needle) (offset uint64, size uint32, isUn
return
}
+ if n.Ttl == needle.EMPTY_TTL && v.Ttl != needle.EMPTY_TTL {
+ n.SetHasTtl()
+ n.Ttl = v.Ttl
+ }
+
n.AppendAtNs = uint64(time.Now().UnixNano())
if offset, size, _, err = n.Append(v.dataFile, v.Version()); err != nil {
return