mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-08-24 05:35:11 +08:00
filer list entries use context to break job
This commit is contained in:
parent
80db8b13d8
commit
47c30e3add
@ -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) {
|
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 {
|
lastFileName, err = f.Store.ListDirectoryPrefixedEntries(ctx, p, startFileName, inclusive, limit, prefix, func(entry *Entry) bool {
|
||||||
if entry.TtlSec > 0 {
|
select {
|
||||||
if entry.Crtime.Add(time.Duration(entry.TtlSec) * time.Second).Before(time.Now()) {
|
case <-ctx.Done():
|
||||||
f.Store.DeleteOneEntry(ctx, entry)
|
return false
|
||||||
expiredCount++
|
default:
|
||||||
return true
|
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 {
|
if err != nil {
|
||||||
return expiredCount, lastFileName, err
|
return expiredCount, lastFileName, err
|
||||||
|
Loading…
Reference in New Issue
Block a user