Browse Source

Fixed TTL expiration check to trigger file deletion on mounted points

pull/5783/head
Andrea Agostini 5 months ago
parent
commit
3ba47b2563
  1. 10
      weed/filer/filer.go

10
weed/filer/filer.go

@ -334,7 +334,10 @@ 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.Crtime.Add(time.Duration(entry.TtlSec) * time.Second).Before(time.Now()) {
f.Store.DeleteOneEntry(ctx, entry)
err = f.doDeleteEntryMetaAndData(ctx, entry, false, false, nil)
if err != nil {
return nil, err
}
return nil, filer_pb.ErrNotFound
}
}
@ -350,7 +353,10 @@ func (f *Filer) doListDirectoryEntries(ctx context.Context, p util.FullPath, sta
default:
if entry.TtlSec > 0 {
if entry.Crtime.Add(time.Duration(entry.TtlSec) * time.Second).Before(time.Now()) {
f.Store.DeleteOneEntry(ctx, entry)
err = f.doDeleteEntryMetaAndData(ctx, entry, false, false, nil)
if err != nil {
return false
}
expiredCount++
return true
}

Loading…
Cancel
Save