17040: RefreshTrashedGroups migration, clear_permissions calls forget_cached_group_perms
authorPeter Amstutz <peter.amstutz@curii.com>
Tue, 3 Nov 2020 17:12:59 +0000 (12:12 -0500)
committerPeter Amstutz <peter.amstutz@curii.com>
Thu, 5 Nov 2020 20:16:35 +0000 (15:16 -0500)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

services/api/app/models/link.rb
services/api/db/migrate/20201103170213_refresh_trashed_groups.rb [new file with mode: 0644]

index eb6ff4c6b80f3a9ad8ecd864dc200fc9122fa11b..83043a56d19026d32a8c3fa65dc839908f74ee86 100644 (file)
@@ -143,6 +143,7 @@ class Link < ArvadosModel
   def clear_permissions
     if self.link_class == 'permission'
       update_permissions tail_uuid, head_uuid, REVOKE_PERM, self.uuid
+      current_user.forget_cached_group_perms
     end
   end
 
diff --git a/services/api/db/migrate/20201103170213_refresh_trashed_groups.rb b/services/api/db/migrate/20201103170213_refresh_trashed_groups.rb
new file mode 100644 (file)
index 0000000..4e8c245
--- /dev/null
@@ -0,0 +1,17 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+require '20200501150153_permission_table_constants'
+
+class RefreshTrashedGroups < ActiveRecord::Migration[5.2]
+  def change
+    # The original refresh_trashed query had a bug, it would insert
+    # all trashed rows, including those with null trash_at times.
+    # This went unnoticed because null trash_at behaved the same as
+    # not having those rows at all, but it is inefficient to fetch
+    # rows we'll never use.  That bug is fixed in the original query
+    # but we need another migration to make sure it runs.
+    refresh_trashed
+  end
+end