From 4651d05c34dfa34177b9afb394f9751900ef9113 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Mon, 11 Feb 2013 07:37:07 -0500 Subject: [PATCH] Local storage: don't try to remove already-renamed tmp file --- storage_local.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/storage_local.go b/storage_local.go index 4edf57c..fcde275 100644 --- a/storage_local.go +++ b/storage_local.go @@ -62,12 +62,12 @@ func (ls *LocalStorage) copyToTmp(src string) (string, error) { func (ls *LocalStorage) Put(filename string, hash string) (e error) { tmpfile, err := ls.copyToTmp(filename) if err != nil { return err } - defer func() { - err := os.Remove(tmpfile) - if err != nil && e == nil { e = err } - }() err = os.Rename(tmpfile, path.Join(ls.storageDir, hash)) + if err != nil { + err := os.Remove(tmpfile) + if err != nil { return err } + } return nil }