diff options
Diffstat (limited to 'weed/filer/filerstore.go')
| -rw-r--r-- | weed/filer/filerstore.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/weed/filer/filerstore.go b/weed/filer/filerstore.go index 11e30878d..3ad7a787e 100644 --- a/weed/filer/filerstore.go +++ b/weed/filer/filerstore.go @@ -45,6 +45,7 @@ type FilerStore interface { type VirtualFilerStore interface { FilerStore DeleteHardLink(ctx context.Context, hardLinkId HardLinkId) error + DeleteOneEntry(ctx context.Context, entry *Entry) error } type FilerStoreWrapper struct { @@ -145,6 +146,23 @@ func (fsw *FilerStoreWrapper) DeleteEntry(ctx context.Context, fp util.FullPath) return fsw.ActualStore.DeleteEntry(ctx, fp) } +func (fsw *FilerStoreWrapper) DeleteOneEntry(ctx context.Context, existingEntry *Entry) (err error) { + stats.FilerStoreCounter.WithLabelValues(fsw.ActualStore.GetName(), "delete").Inc() + start := time.Now() + defer func() { + stats.FilerStoreHistogram.WithLabelValues(fsw.ActualStore.GetName(), "delete").Observe(time.Since(start).Seconds()) + }() + + if len(existingEntry.HardLinkId) != 0 { + // remove hard link + if err = fsw.DeleteHardLink(ctx, existingEntry.HardLinkId); err != nil { + return err + } + } + + return fsw.ActualStore.DeleteEntry(ctx, existingEntry.FullPath) +} + func (fsw *FilerStoreWrapper) DeleteFolderChildren(ctx context.Context, fp util.FullPath) (err error) { stats.FilerStoreCounter.WithLabelValues(fsw.ActualStore.GetName(), "deleteFolderChildren").Inc() start := time.Now() |
