[ARVADOS] updated: f560e8aeb2a61cd4941f84e4fe119d27eefe6d8f

git at public.curoverse.com git at public.curoverse.com
Mon Jun 8 21:44:52 EDT 2015


Summary of changes:
 services/api/app/models/collection.rb | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

       via  f560e8aeb2a61cd4941f84e4fe119d27eefe6d8f (commit)
      from  0e93a99cee72ca54650c6e9aa41af3fb5adc869a (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 f560e8aeb2a61cd4941f84e4fe119d27eefe6d8f
Author: radhika <radhika at curoverse.com>
Date:   Mon Jun 8 21:42:30 2015 -0400

    6203: Use LOCATION_REGEXP from sdk; also add back updated each_manifest_locator method
    with the same updates as munge method since this is simpler than the munge method. This
    has seems further improved performance.

diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb
index 1d11315..16e32d9 100644
--- a/services/api/app/models/collection.rb
+++ b/services/api/app/models/collection.rb
@@ -29,8 +29,6 @@ class Collection < ArvadosModel
     t.add :replication_confirmed_at
   end
 
-  LOCATOR_REGEXP = /^([[:xdigit:]]{32})(\+([[:digit:]]+))?(\+([[:upper:]][[:alnum:]+ at _-]*))?$/
-
   def self.attributes_required_columns
     super.merge(
                 # If we don't list manifest_text explicitly, the
@@ -94,19 +92,21 @@ class Collection < ArvadosModel
 
   def strip_signatures_and_update_replication_confirmed
     if self.manifest_text_changed?
+      # If the new manifest_text contains locators whose hashes
+      # weren't in the old manifest_text, storage replication is no
+      # longer confirmed.
       in_old_manifest = {}
-      self.class.munge_manifest_locators(manifest_text_was) do |match|
-        in_old_manifest[match[1]] = true
+      if not self.replication_confirmed.nil?
+        self.class.each_manifest_locator(manifest_text_was) do |match|
+          in_old_manifest[match[1]] = true
+        end
       end
 
-      cleared_replication_confirmed = false
-
       # Remove any permission signatures from the manifest.
       self[:manifest_text] = self.class.munge_manifest_locators(self[:manifest_text]) do |match|
-        if not cleared_replication_confirmed  and not in_old_manifest[match[1]]
+        if not self.replication_confirmed.nil? and not in_old_manifest[match[1]]
           self.replication_confirmed_at = nil
           self.replication_confirmed = nil
-          cleared_replication_confirmed = true
         end
         match[0].gsub(/\+A[^+]*/, '')
       end
@@ -227,7 +227,7 @@ class Collection < ArvadosModel
       words = line.split(' ')
       new_words = []
       words.each do |word|
-        if match = LOCATOR_REGEXP.match(word)
+        if match = Keep::Locator::LOCATOR_REGEXP.match(word)
           new_words << yield(match)
         else
           new_words << word
@@ -239,6 +239,19 @@ class Collection < ArvadosModel
     manifest = new_lines.join("\n") + "\n"
   end
 
+  def self.each_manifest_locator manifest
+    # Given a manifest text and a block, yield each locator.
+    manifest.each_line do |line|
+      line.rstrip!
+      words = line.split(' ')
+      words.each do |word|
+        if match = Keep::Locator::LOCATOR_REGEXP.match(word)
+          yield(match)
+        end
+      end
+    end
+  end
+
   def self.normalize_uuid uuid
     hash_part = nil
     size_part = nil

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list