GetS3ExpireTime on filer

This commit is contained in:
Konstantin Lebedev
2025-11-04 10:29:16 +05:00
parent f8b874d752
commit 981bc96082
2 changed files with 22 additions and 6 deletions
+17
View File
@@ -1,6 +1,7 @@
package filer
import (
"github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants"
"os"
"time"
@@ -143,3 +144,19 @@ func maxUint64(x, y uint64) uint64 {
}
return y
}
func (entry *Entry) IsExpireS3Enabled() (found bool) {
if entry.Extended != nil {
_, found = entry.Extended[s3_constants.SeaweedFSExpiresS3]
}
return found
}
func (entry *Entry) GetS3ExpireTime() (expireTime time.Time) {
if entry.Mtime.IsZero() {
expireTime = entry.Crtime
} else {
expireTime = entry.Mtime
}
return expireTime.Add(time.Duration(entry.TtlSec) * time.Second)
}
+5 -6
View File
@@ -8,7 +8,6 @@ import (
"strings"
"time"
"github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants"
"github.com/seaweedfs/seaweedfs/weed/s3api/s3bucket"
"github.com/seaweedfs/seaweedfs/weed/cluster/lock_manager"
@@ -352,12 +351,12 @@ func (f *Filer) FindEntry(ctx context.Context, p util.FullPath) (entry *Entry, e
}
entry, err = f.Store.FindEntry(ctx, p)
if entry != nil && entry.TtlSec > 0 {
if entry.Extended != nil {
if _, found := entry.Extended[s3_constants.SeaweedFSExpiresS3]; found {
return
if entry.IsExpireS3Enabled() {
if entry.GetS3ExpireTime().Before(time.Now()) {
f.Store.DeleteOneEntry(ctx, entry)
return nil, filer_pb.ErrNotFound
}
}
if entry.Crtime.Add(time.Duration(entry.TtlSec) * time.Second).Before(time.Now()) {
} else if entry.Crtime.Add(time.Duration(entry.TtlSec) * time.Second).Before(time.Now()) {
f.Store.DeleteOneEntry(ctx, entry)
return nil, filer_pb.ErrNotFound
}