policy: Recalculate permission mode after setting a new one (#3280)

`mc policy set` can confuse users by showing that a bucket has 'none'
policy mode although issuing `mc policy get` will show it is `custom`
when the bucket already other policy statements for some sub-resources.

For better UX, mc will issue another request to get the real policy
mode.
This commit is contained in:
Anis Elleuch
2020-07-10 22:17:54 -07:00
committed by Harshavardhana
parent 8f3d514e3b
commit b97b7b8987
+4 -1
View File
@@ -437,8 +437,11 @@ func runPolicyCmd(args cli.Args) {
perms := accessPerms(args.Get(1))
targetURL := args.Get(2)
if perms.isValidAccessPERM() {
probeErr = doSetAccess(ctx, targetURL, perms)
operation = "set"
probeErr = doSetAccess(ctx, targetURL, perms)
if probeErr == nil {
perms, _, probeErr = doGetAccess(ctx, targetURL)
}
} else if perms.isValidAccessFile() {
probeErr = doSetAccessJSON(ctx, targetURL, perms)
operation = "set-json"