aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2021-12-28 01:10:38 -0800
committerchrislu <chris.lu@gmail.com>2021-12-28 01:10:38 -0800
commit3fd4da34a4070371c43e18ac45b568cdb94a520e (patch)
treee64db17831ee189447648c61d3d7d77d2679d3ca
parent242255645604e9974c01257f5d1177eba95fff42 (diff)
parent6c8caea09cf40d27d0404c408bd5792d43256534 (diff)
downloadseaweedfs-3fd4da34a4070371c43e18ac45b568cdb94a520e.tar.xz
seaweedfs-3fd4da34a4070371c43e18ac45b568cdb94a520e.zip
Merge branch 'master' of https://github.com/chrislusf/seaweedfs
-rw-r--r--weed/filer/filer.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/weed/filer/filer.go b/weed/filer/filer.go
index 7ca198b38..0f34adb4d 100644
--- a/weed/filer/filer.go
+++ b/weed/filer/filer.go
@@ -306,14 +306,19 @@ func (f *Filer) FindEntry(ctx context.Context, p util.FullPath) (entry *Entry, e
func (f *Filer) doListDirectoryEntries(ctx context.Context, p util.FullPath, startFileName string, inclusive bool, limit int64, prefix string, eachEntryFunc ListEachEntryFunc) (expiredCount int64, lastFileName string, err error) {
lastFileName, err = f.Store.ListDirectoryPrefixedEntries(ctx, p, startFileName, inclusive, limit, prefix, func(entry *Entry) bool {
- if entry.TtlSec > 0 {
- if entry.Crtime.Add(time.Duration(entry.TtlSec) * time.Second).Before(time.Now()) {
- f.Store.DeleteOneEntry(ctx, entry)
- expiredCount++
- return true
+ select {
+ case <-ctx.Done():
+ return false
+ default:
+ if entry.TtlSec > 0 {
+ if entry.Crtime.Add(time.Duration(entry.TtlSec) * time.Second).Before(time.Now()) {
+ f.Store.DeleteOneEntry(ctx, entry)
+ expiredCount++
+ return true
+ }
}
+ return eachEntryFunc(entry)
}
- return eachEntryFunc(entry)
})
if err != nil {
return expiredCount, lastFileName, err