[ARVADOS] updated: 9e17d8df4c60295ce81bd229e723dc37b7b98b9b

Git user git at public.curoverse.com
Wed May 11 10:29:02 EDT 2016


Summary of changes:
 services/api/app/models/group.rb |  2 +-
 services/api/app/models/user.rb  | 26 ++++++++++++++++++--------
 2 files changed, 19 insertions(+), 9 deletions(-)

       via  9e17d8df4c60295ce81bd229e723dc37b7b98b9b (commit)
      from  e711e48313021fb79e6ef65595af48c92a0caafc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 9e17d8df4c60295ce81bd229e723dc37b7b98b9b
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Wed May 11 09:50:23 2016 -0400

    8886: Restore behavior in group_permissions to call
    calculate_group_permissions when cache is empty and async_permissions_update is
    not true.

diff --git a/services/api/app/models/group.rb b/services/api/app/models/group.rb
index ac3309b..6105b5f 100644
--- a/services/api/app/models/group.rb
+++ b/services/api/app/models/group.rb
@@ -20,7 +20,7 @@ class Group < ArvadosModel
     if uuid_changed? or owner_uuid_changed?
       # This can change users' permissions on other groups as well as
       # this one.
-      invalidate_permissions_cache db_current_time.to_i
+      invalidate_permissions_cache
     end
   end
 
diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb
index 3cb595b..553a3be 100644
--- a/services/api/app/models/user.rb
+++ b/services/api/app/models/user.rb
@@ -123,14 +123,22 @@ class User < ArvadosModel
     true
   end
 
-  def self.invalidate_permissions_cache timestamp
+  def self.invalidate_permissions_cache(timestamp=nil)
     if Rails.configuration.async_permissions_update
+      timestamp = DbCurrentTime::db_current_time.to_i if timestamp.nil?
       connection.execute "NOTIFY invalidate_permissions_cache, '#{timestamp}'"
     else
       Rails.cache.delete_matched(/^groups_for_user_/)
     end
   end
 
+  # Return a hash of {group_uuid: perm_hash} where perm_hash[:read]
+  # and perm_hash[:write] are true if this user can read and write
+  # objects owned by group_uuid.
+  #
+  # The permission graph is built by repeatedly enumerating all
+  # permission links reachable from self.uuid, and then calling
+  # search_permissions
   def calculate_group_permissions
       permissions_from = {}
       todo = {self.uuid => true}
@@ -186,15 +194,17 @@ class User < ArvadosModel
   # Return a hash of {group_uuid: perm_hash} where perm_hash[:read]
   # and perm_hash[:write] are true if this user can read and write
   # objects owned by group_uuid.
-  #
-  # The permission graph is built by repeatedly enumerating all
-  # permission links reachable from self.uuid, and then calling
-  # search_permissions
   def group_permissions
     r = Rails.cache.read "groups_for_user_#{self.uuid}"
-    while r.nil?
-      sleep(0.1)
-      r = Rails.cache.read "groups_for_user_#{self.uuid}"
+    if r.nil?
+      if Rails.configuration.async_permissions_update
+        while r.nil?
+          sleep(0.1)
+          r = Rails.cache.read "groups_for_user_#{self.uuid}"
+        end
+      else
+        r = calculate_group_permissions
+      end
     end
     r
   end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list