17152: Changes preserve_version semantics, updates related documentation.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Thu, 10 Dec 2020 19:53:49 +0000 (16:53 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Thu, 10 Dec 2020 22:21:18 +0000 (19:21 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

doc/admin/upgrading.html.textile.liquid
doc/api/methods/collections.html.textile.liquid
services/api/app/models/collection.rb

index 3f622112e95391d5364be1e16f211729b2c4a150..ac697d87071ce4d31ce59ec5015d93d1f50f8c79 100644 (file)
@@ -35,10 +35,14 @@ TODO: extract this information based on git commit messages and generate changel
 <div class="releasenotes">
 </notextile>
 
-h2(#main). development main (as of 2020-10-28)
+h2(#main). development main (as of 2020-12-10)
 
 "Upgrading from 2.1.0":#v2_1_0
 
+h3. Changes on the collection's @preserve_version@ attribute semantics
+
+The @preserve_version@ attribute on collections was originally designed to allow clients to persist a preexisting collection version. This forced clients to make 2 requests if the intention is to "make this set of changes in a new version that will be kept", so we have changed the semantics to do just that: When passing @preserve_version=true@ along with other collection updates, the current version is persisted and also the newly created one will be persisted on the next update.
+
 h3. Centos7 Python 3 dependency upgraded to python3
 
 Now that Python 3 is part of the base repository in CentOS 7, the Python 3 dependency for Centos7 Arvados packages was changed from SCL rh-python36 to python3.
index 4372cc2f5e7dd17bd2c662bf7224cf6fdd5d4c6f..fd4a36f291ae90641a2e48606af66b35311c0780 100644 (file)
@@ -38,7 +38,7 @@ table(table table-bordered table-condensed).
 |is_trashed|boolean|True if @trash_at@ is in the past, false if not.||
 |current_version_uuid|string|UUID of the collection's current version. On new collections, it'll be equal to the @uuid@ attribute.||
 |version|number|Version number, starting at 1 on new collections. This attribute is read-only.||
-|preserve_version|boolean|When set to true on a current version, it will be saved on the next versionable update.||
+|preserve_version|boolean|When set to true on a current version, it will be persisted. When passing @true@ as part of a bigger update call, both current and newly created versions are persisted.||
 |file_count|number|The total number of files in the collection. This attribute is read-only.||
 |file_size_total|number|The sum of the file sizes in the collection. This attribute is read-only.||
 
index 3637f34e105b1bd66013a7cc0882860dc434034e..919d2fcb40814770952470b0ab543c57a6425417 100644 (file)
@@ -37,6 +37,8 @@ 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|
@@ -286,7 +288,9 @@ class Collection < ArvadosModel
 
       if should_preserve_version
         self.version += 1
-        self.preserve_version = false
+        if !changes.keys.include?('preserve_version')
+          self.preserve_version = false
+        end
       end
 
       yield
@@ -305,6 +309,10 @@ class Collection < ArvadosModel
     end
   end
 
+  def preserve_version_exclusive_updates_leave_modified_at_alone
+    self.modified_at = self.modified_at_was
+  end
+
   def syncable_updates
     updates = {}
     if self.changes.any?
@@ -359,6 +367,7 @@ class Collection < ArvadosModel
 
     idle_threshold = Rails.configuration.Collections.PreserveVersionIfIdle
     if !self.preserve_version_was &&
+      !self.preserve_version &&
       (idle_threshold < 0 ||
         (idle_threshold > 0 && self.modified_at_was > db_current_time-idle_threshold.seconds))
       return false