From ee2168a8555c201d8c5ed036cae68aa4c38fe228 Mon Sep 17 00:00:00 2001 From: Rupak Ganguly Date: Mon, 29 Oct 2012 17:01:21 -0400 Subject: [PATCH] Minor bug fix when acls are nil. Also, added support for specifying list of users for grant and revoke as a comma-separated list. --- lib/fog/hp/models/storage/directory.rb | 28 ++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/fog/hp/models/storage/directory.rb b/lib/fog/hp/models/storage/directory.rb index 33bc60a59..15900d849 100644 --- a/lib/fog/hp/models/storage/directory.rb +++ b/lib/fog/hp/models/storage/directory.rb @@ -52,26 +52,38 @@ module Fog return users end - def grant(perm, users=[]) - r_acl, w_acl = connection.perm_to_acl(perm, users) - unless r_acl.nil? + def grant(perm, users=nil) + # support passing in a list of users in a comma-separated list or as an Array + if users.is_a?(String) + user_list = users.split(',') + else + user_list = users + end + r_acl, w_acl = connection.perm_to_acl(perm, user_list) + unless r_acl.nil? || r_acl.empty? @read_acl = @read_acl + r_acl @read_acl.uniq! end - unless w_acl.nil? + unless w_acl.nil? || w_acl.empty? @write_acl = @write_acl + w_acl @write_acl.uniq! end true end - def revoke(perm, users=[]) - r_acl, w_acl = connection.perm_to_acl(perm, users) - unless r_acl.nil? + def revoke(perm, users=nil) + # support passing in a list of users in a comma-separated list or as an Array + if users.is_a?(String) + user_list = users.split(',') + else + user_list = users + end + r_acl, w_acl = connection.perm_to_acl(perm, user_list) + unless (r_acl.nil? || r_acl.empty?) && (@read_acl.nil? || @read_acl.empty?) @read_acl = @read_acl - r_acl @read_acl.uniq! end - unless w_acl.nil? + unless (w_acl.nil? || w_acl.empty?) && (@write_acl.nil? || @write_acl.empty?) @write_acl = @write_acl - w_acl @write_acl.uniq! end