[arvados] updated: 2.7.0-5501-ge94ff3afe8

git repository hosting git at public.arvados.org
Tue Dec 5 15:10:48 UTC 2023


Summary of changes:
 services/api/app/models/link.rb | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

       via  e94ff3afe8d6f8aaca53dd9f3cd3d958c5364df6 (commit)
      from  87236b449bd37c6c2980eeabcb105613a72c0843 (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 e94ff3afe8d6f8aaca53dd9f3cd3d958c5364df6
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Tue Dec 5 10:07:04 2023 -0500

    21160: Avoid redundant work
    
    Don't recompute permissions on a link update that doesn't change
    anything.
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/services/api/app/models/link.rb b/services/api/app/models/link.rb
index 4d4c2832bb..2eb6b88a0c 100644
--- a/services/api/app/models/link.rb
+++ b/services/api/app/models/link.rb
@@ -17,11 +17,12 @@ class Link < ArvadosModel
   before_update :apply_max_overlapping_permissions
   before_create :apply_max_overlapping_permissions
   after_update :delete_overlapping_permissions
-  after_update :call_update_permissions
-  after_create :call_update_permissions
+  after_update :call_update_permissions, :if => Proc.new { @need_update_permissions }
+  after_create :call_update_permissions, :if => Proc.new { @need_update_permissions }
   before_destroy :clear_permissions
   after_destroy :delete_overlapping_permissions
   after_destroy :check_permissions
+  before_save :check_need_update_permissions
 
   api_accessible :user, extend: :common do |t|
     t.add :tail_uuid
@@ -189,11 +190,13 @@ class Link < ArvadosModel
     'can_manage' => 3,
   }
 
+  def check_need_update_permissions
+    @need_update_permissions = self.link_class == 'permission' && (name != name_was || new_record?)
+  end
+
   def call_update_permissions
-    if self.link_class == 'permission'
       update_permissions tail_uuid, head_uuid, PERM_LEVEL[name], self.uuid
       current_user.forget_cached_group_perms
-    end
   end
 
   def clear_permissions

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list