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-01 09:22:22 -07:00
committed by GitHub
parent b8570a9a0b
commit 90d6e7df24
+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"