1
0
Fork 0

Local storage: don't try to remove already-renamed tmp file

This commit is contained in:
Aaron Lindsay 2013-02-11 07:37:07 -05:00
parent a045104016
commit 4651d05c34
1 changed files with 4 additions and 4 deletions

View File

@ -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
}