fix ttl objects
fix https://github.com/seaweedfs/seaweedfs/discussions/7107#discussioncomment-14069018
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/seaweedfs/seaweedfs/weed/filer"
|
"github.com/seaweedfs/seaweedfs/weed/filer"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||||
@@ -265,7 +266,21 @@ func (store *TikvStore) ListDirectoryPrefixedEntries(ctx context.Context, dirPat
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only increment counter after successful processing
|
// Check TTL expiration before calling eachEntryFunc (similar to Redis stores)
|
||||||
|
if entry.TtlSec > 0 {
|
||||||
|
if entry.Crtime.Add(time.Duration(entry.TtlSec) * time.Second).Before(time.Now()) {
|
||||||
|
// Entry is expired, delete it and continue without counting toward limit
|
||||||
|
if deleteErr := store.DeleteEntry(ctx, entry.FullPath); deleteErr != nil {
|
||||||
|
glog.V(0).InfofCtx(ctx, "failed to delete expired entry %s: %v", entry.FullPath, deleteErr)
|
||||||
|
}
|
||||||
|
if err := iter.Next(); err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only increment counter for non-expired entries
|
||||||
i++
|
i++
|
||||||
|
|
||||||
if err := iter.Next(); !eachEntryFunc(entry) || err != nil {
|
if err := iter.Next(); !eachEntryFunc(entry) || err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user