fs: Fail createObject with appropriate message.

Fail createObject() if a file already exists and one attempts
to create a prefix/directory by same name.

Send an approriate error back to the client as 409 Conflict.
This commit is contained in:
Harshavardhana
2016-02-02 15:23:28 -08:00
parent 729e032a50
commit 835b297ba7
4 changed files with 59 additions and 31 deletions

View File

@@ -74,6 +74,7 @@ const (
SignatureVersionNotSupported
BucketNotEmpty
RootPathFull
ObjectExistsAsPrefix
)
// APIError code to Error structure map
@@ -238,6 +239,11 @@ var errorCodeResponse = map[int]APIError{
Description: "Root path has reached its minimum free disk threshold. Please delete few objects to proceed.",
HTTPStatusCode: http.StatusInternalServerError,
},
ObjectExistsAsPrefix: {
Code: "ObjectExistsAsPrefix",
Description: "An object already exists as your prefix, choose a different prefix to proceed.",
HTTPStatusCode: http.StatusConflict,
},
}
// errorCodeError provides errorCode to Error. It returns empty if the code provided is unknown