Browse Source

Merge pull request #2539 from ck789987/filer-list-use-context

filer list entries use context to break job
pull/2550/head
Chris Lu 3 years ago
committed by GitHub
parent
commit
6c8caea09c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      weed/filer/filer.go

5
weed/filer/filer.go

@ -306,6 +306,10 @@ 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 {
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)
@ -314,6 +318,7 @@ func (f *Filer) doListDirectoryEntries(ctx context.Context, p util.FullPath, sta
}
}
return eachEntryFunc(entry)
}
})
if err != nil {
return expiredCount, lastFileName, err

Loading…
Cancel
Save