diff options
| author | Chris Lu <chris.lu@gmail.com> | 2019-06-26 11:18:23 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2019-06-26 11:18:23 -0700 |
| commit | c2960c7a861d5e827143731274cf04e4e5c8f584 (patch) | |
| tree | e5c60606277284716a769e4e4b46c599eb53ef17 | |
| parent | 06140f9313ddf1eeed1ccdd5065b0b460e2ab569 (diff) | |
| download | seaweedfs-c2960c7a861d5e827143731274cf04e4e5c8f584.tar.xz seaweedfs-c2960c7a861d5e827143731274cf04e4e5c8f584.zip | |
defaulting file ttl to volume ttl
fix https://github.com/chrislusf/seaweedfs/issues/992
| -rw-r--r-- | weed/storage/needle/volume_ttl.go | 3 | ||||
| -rw-r--r-- | weed/storage/volume_read_write.go | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/weed/storage/needle/volume_ttl.go b/weed/storage/needle/volume_ttl.go index 0b4c9579b..4a169870d 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 bd268c1a6..93ce1eab9 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 |
