mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-04 07:07:18 +00:00
GetS3ExpireTime on filer
This commit is contained in:
@@ -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
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user