From db0c25b3d8f4bc14c584c381b6fcdf300be4678d Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 17 Jun 2018 13:02:22 -0700 Subject: [PATCH] delete old entry only after successful insert --- weed/filer2/filer.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/weed/filer2/filer.go b/weed/filer2/filer.go index cf6b4ba28..53de5bea3 100644 --- a/weed/filer2/filer.go +++ b/weed/filer2/filer.go @@ -104,14 +104,14 @@ func (f *Filer) CreateEntry(entry *Entry) error { } */ - if oldEntry, err := f.FindEntry(entry.FullPath); err == nil { - f.deleteChunks(oldEntry) - } + oldEntry, _ := f.FindEntry(entry.FullPath) if err := f.store.InsertEntry(entry); err != nil { return fmt.Errorf("insert entry %s: %v", entry.FullPath, err) } + f.deleteChunks(oldEntry) + return nil }