mirror of
https://github.com/pgsty/minio.git
synced 2026-07-24 22:46:16 +03:00
Persist MINIO_WORM as part of config.json (#6022)
This commit is contained in:
committed by
kannappanr
parent
113570b514
commit
6138cae8e7
+19
-1
@@ -353,6 +353,13 @@ next:
|
||||
for _, objectName := range args.Objects {
|
||||
// If not a directory, remove the object.
|
||||
if !hasSuffix(objectName, slashSeparator) && objectName != "" {
|
||||
// Deny if WORM is enabled
|
||||
if globalWORMEnabled {
|
||||
if _, err = objectAPI.GetObjectInfo(context.Background(), args.BucketName, objectName); err == nil {
|
||||
return toJSONError(errMethodNotAllowed)
|
||||
}
|
||||
}
|
||||
|
||||
if err = deleteObject(nil, objectAPI, web.CacheAPI(), args.BucketName, objectName, r); err != nil {
|
||||
break next
|
||||
}
|
||||
@@ -457,7 +464,7 @@ func (web *webAPIHandlers) SetAuth(r *http.Request, args *SetAuthArgs, reply *Se
|
||||
}
|
||||
|
||||
// If creds are set through ENV disallow changing credentials.
|
||||
if globalIsEnvCreds {
|
||||
if globalIsEnvCreds || globalWORMEnabled {
|
||||
return toJSONError(errChangeCredNotAllowed)
|
||||
}
|
||||
|
||||
@@ -594,6 +601,14 @@ func (web *webAPIHandlers) Upload(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Deny if WORM is enabled
|
||||
if globalWORMEnabled {
|
||||
if _, err = objectAPI.GetObjectInfo(context.Background(), bucket, object); err == nil {
|
||||
writeWebErrorResponse(w, errMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
objInfo, err := putObject(context.Background(), bucket, object, hashReader, metadata)
|
||||
if err != nil {
|
||||
writeWebErrorResponse(w, err)
|
||||
@@ -1103,7 +1118,10 @@ func toWebAPIError(err error) APIError {
|
||||
HTTPStatusCode: http.StatusBadRequest,
|
||||
Description: err.Error(),
|
||||
}
|
||||
} else if err == errMethodNotAllowed {
|
||||
return getAPIError(ErrMethodNotAllowed)
|
||||
}
|
||||
|
||||
// Convert error type to api error code.
|
||||
switch err.(type) {
|
||||
case StorageFull:
|
||||
|
||||
Reference in New Issue
Block a user