17152: Improves modified_at conditional update check.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Mon, 14 Dec 2020 13:31:14 +0000 (10:31 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Mon, 14 Dec 2020 13:31:14 +0000 (10:31 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

services/api/app/models/collection.rb

index c2c60ec70e0202038151206eb1ace452fe1d1268..4e7b64cf5374fb38003d70790aebd8caee0931fb 100644 (file)
@@ -37,8 +37,6 @@ class Collection < ArvadosModel
   validate :protected_managed_properties_updates, on: :update
   after_validation :set_file_count_and_total_size
   before_save :set_file_names
-  before_update :preserve_version_exclusive_updates_leave_modified_at_alone,
-    if: Proc.new { |col| col.changes.keys.sort == ['modified_at', 'updated_at', 'preserve_version'].sort }
   around_update :manage_versioning, unless: :is_past_version?
 
   api_accessible :user, extend: :common do |t|
@@ -308,8 +306,10 @@ class Collection < ArvadosModel
     end
   end
 
-  def preserve_version_exclusive_updates_leave_modified_at_alone
-    self.modified_at = self.modified_at_was
+  def maybe_update_modified_by_fields
+    if !(self.changes.keys - ['updated_at', 'preserve_version']).empty?
+      super
+    end
   end
 
   def syncable_updates