diff options
| author | chrislu <chris.lu@gmail.com> | 2025-11-05 16:31:17 -0800 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2025-11-05 16:31:17 -0800 |
| commit | 9866287d8d3f50f6ad5fefc003e7651f67737607 (patch) | |
| tree | 2c639c0ce69c5d7bdf3f21207b6edc7e9d01e7cc | |
| parent | 06e9ca70a64118622fd66f242f72ac03d4bcc811 (diff) | |
| download | seaweedfs-9866287d8d3f50f6ad5fefc003e7651f67737607.tar.xz seaweedfs-9866287d8d3f50f6ad5fefc003e7651f67737607.zip | |
s3 TTL time
| -rw-r--r-- | weed/pb/filer_pb/filer_pb_helper.go | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/weed/pb/filer_pb/filer_pb_helper.go b/weed/pb/filer_pb/filer_pb_helper.go index 3ce494716..c8dd19d59 100644 --- a/weed/pb/filer_pb/filer_pb_helper.go +++ b/weed/pb/filer_pb/filer_pb_helper.go @@ -9,6 +9,7 @@ import ( "time" "github.com/seaweedfs/seaweedfs/weed/glog" + "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants" "github.com/seaweedfs/seaweedfs/weed/storage/needle" "github.com/viant/ptrie" "google.golang.org/protobuf/proto" @@ -25,11 +26,22 @@ func (entry *Entry) IsDirectoryKeyObject() bool { } func (entry *Entry) GetExpiryTime() (expiryTime int64) { - expiryTime = entry.Attributes.Mtime - if expiryTime == 0 { - expiryTime = entry.Attributes.Crtime + // For S3 objects with lifecycle expiration, use Mtime (modification time) + // For regular TTL entries, use Crtime (creation time) for backward compatibility + if entry.Extended != nil { + if _, hasS3Expiry := entry.Extended[s3_constants.SeaweedFSExpiresS3]; hasS3Expiry { + // S3 lifecycle expiration: base TTL on modification time + expiryTime = entry.Attributes.Mtime + if expiryTime == 0 { + expiryTime = entry.Attributes.Crtime + } + expiryTime += int64(entry.Attributes.TtlSec) + return expiryTime + } } - expiryTime += int64(entry.Attributes.TtlSec) + + // Regular TTL expiration: base on creation time only + expiryTime = entry.Attributes.Crtime + int64(entry.Attributes.TtlSec) return expiryTime } |
