[ARVADOS] created: 1.3.0-36-g2aa58f31a
Git user
git at public.curoverse.com
Thu Dec 13 14:38:12 EST 2018
at 2aa58f31ac8fc696361214a05ab9ba75a5140b08 (commit)
commit 2aa58f31ac8fc696361214a05ab9ba75a5140b08
Author: Peter Amstutz <pamstutz at veritasgenetics.com>
Date: Thu Dec 13 14:37:29 2018 -0500
14595: Add leave_modified_at_alone
leave_modified_by_user_alone does not affect modified_at
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>
diff --git a/services/api/app/models/arvados_model.rb b/services/api/app/models/arvados_model.rb
index 93d5b9a02..eea95e2be 100644
--- a/services/api/app/models/arvados_model.rb
+++ b/services/api/app/models/arvados_model.rb
@@ -557,6 +557,8 @@ class ArvadosModel < ActiveRecord::Base
self.owner_uuid ||= current_default_owner if self.respond_to? :owner_uuid=
if !anonymous_updater
self.modified_by_user_uuid = current_user ? current_user.uuid : nil
+ end
+ if !timeless_updater
self.modified_at = current_time
end
self.modified_by_client_uuid = current_api_client ? current_api_client.uuid : nil
diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb
index 487043ee3..33cc686d4 100644
--- a/services/api/app/models/collection.rb
+++ b/services/api/app/models/collection.rb
@@ -287,7 +287,9 @@ class Collection < ArvadosModel
# Use a different validation context to skip the 'old_versions_cannot_be_updated'
# validator, as on this case it is legal to update some fields.
leave_modified_by_user_alone do
- c.save(context: :update_old_versions)
+ leave_modified_at_alone do
+ c.save(context: :update_old_versions)
+ end
end
end
end
diff --git a/services/api/lib/arvados_model_updates.rb b/services/api/lib/arvados_model_updates.rb
index b456bd395..0a07574a5 100644
--- a/services/api/lib/arvados_model_updates.rb
+++ b/services/api/lib/arvados_model_updates.rb
@@ -18,4 +18,21 @@ module ArvadosModelUpdates
Thread.current[:anonymous_updater] = anonymous_updater_was
end
end
+
+ # ArvadosModel checks this to decide whether it should update the
+ # 'modified_at_uuid' field.
+ def timeless_updater
+ Thread.current[:timeless_updater] || false
+ end
+
+ def leave_modified_at_alone
+ timeless_updater_was = timeless_updater
+ begin
+ Thread.current[:timeless_updater] = true
+ yield
+ ensure
+ Thread.current[:timeless_updater] = timeless_updater_was
+ end
+ end
+
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list