s3/local backend: Fix error for overwriting files

This commit is contained in:
Alexander Neumann 2016-01-24 21:13:24 +01:00
parent 1547d3b656
commit d9c87559b5
2 changed files with 16 additions and 5 deletions

View file

@ -2,6 +2,7 @@ package s3
import (
"bytes"
"errors"
"io"
"strings"
@ -103,6 +104,13 @@ func (be S3Backend) Save(h backend.Handle, p []byte) (err error) {
path := s3path(h.Type, h.Name)
// Check key does not already exist
_, err = be.client.StatObject(be.bucketname, path)
if err == nil {
debug.Log("s3.blob.Finalize()", "%v already exists", h)
return errors.New("key already exists")
}
<-be.connChan
defer func() {
be.connChan <- struct{}{}