X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/966bd97704f635315ab7ba50f23590a5fc9a97be..08c575dc24bbc5732a5fcb1126c23d9a4ca10b73:/services/api/app/models/collection.rb diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb index 3ab97bf095..ebe88b4775 100644 --- a/services/api/app/models/collection.rb +++ b/services/api/app/models/collection.rb @@ -9,7 +9,7 @@ class Collection < ArvadosModel before_validation :check_signatures before_validation :strip_manifest_text before_validation :set_portable_data_hash - before_validation :maybe_clear_redundancy_confirmed + before_validation :maybe_clear_replication_confirmed validate :ensure_hash_matches_manifest_text before_save :set_file_names @@ -205,7 +205,7 @@ class Collection < ArvadosModel def self.munge_manifest_locators! manifest # Given a manifest text and a block, yield each locator, # and replace it with whatever the block returns. - manifest.andand.gsub!(/ [[:xdigit:]]{32}(\+[[:digit:]]+)?(\+\S+)/) do |word| + manifest.andand.gsub!(/ [[:xdigit:]]{32}(\+\S+)?/) do |word| if loc = Keep::Locator.parse(word.strip) " " + yield(loc) else @@ -216,8 +216,8 @@ class Collection < ArvadosModel def self.each_manifest_locator manifest # Given a manifest text and a block, yield each locator. - manifest.andand.scan(/ ([[:xdigit:]]{32}(\+[[:digit:]]+)?(\+\S+))/) do |word| - if loc = Keep::Locator.parse(word[1]) + manifest.andand.scan(/ ([[:xdigit:]]{32}(\+\S+)?)/) do |word, _| + if loc = Keep::Locator.parse(word) yield loc end end @@ -308,7 +308,11 @@ class Collection < ArvadosModel def portable_manifest_text portable_manifest = self[:manifest_text].dup self.class.munge_manifest_locators!(portable_manifest) do |loc| - loc.hash + '+' + loc.size.to_s + if loc.size + loc.hash + '+' + loc.size.to_s + else + loc.hash + end end portable_manifest end @@ -320,7 +324,7 @@ class Collection < ArvadosModel portable_manifest.bytesize.to_s) end - def maybe_clear_redundancy_confirmed + def maybe_clear_replication_confirmed if manifest_text_changed? # If the new manifest_text contains locators whose hashes # weren't in the old manifest_text, storage replication is no @@ -331,8 +335,8 @@ class Collection < ArvadosModel end self.class.each_manifest_locator(manifest_text) do |loc| if not in_old_manifest[loc.hash] - replication_confirmed_at = nil - replication_confirmed = nil + self.replication_confirmed_at = nil + self.replication_confirmed = nil break end end