X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/7eb7c12b0aabda5c937922a9696200ed13b5f51f..72bac44ada0faa8bf039fb0ffea0f069d7c59310:/services/api/app/models/collection.rb diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb index 39d56997a0..caac5611e7 100644 --- a/services/api/app/models/collection.rb +++ b/services/api/app/models/collection.rb @@ -27,6 +27,8 @@ class Collection < ArvadosModel before_validation :check_manifest_validity before_validation :check_signatures before_validation :strip_signatures_and_update_replication_confirmed + before_validation :name_null_if_empty + validate :ensure_filesystem_compatible_name validate :ensure_pdh_matches_manifest_text validate :ensure_storage_classes_desired_is_not_empty validate :ensure_storage_classes_contain_non_empty_strings @@ -38,7 +40,7 @@ class Collection < ArvadosModel around_update :manage_versioning, unless: :is_past_version? api_accessible :user, extend: :common do |t| - t.add :name + t.add lambda { |x| x.name || "" }, as: :name t.add :description t.add :properties t.add :portable_data_hash @@ -77,6 +79,7 @@ class Collection < ArvadosModel # correct timestamp in signed_manifest_text. 'manifest_text' => ['manifest_text', 'trash_at', 'is_trashed'], 'unsigned_manifest_text' => ['manifest_text'], + 'name' => ['name'], ) end @@ -195,6 +198,12 @@ class Collection < ArvadosModel end end + def name_null_if_empty + if name == "" + self.name = nil + end + end + def set_file_names if self.manifest_text_changed? self.file_names = manifest_files @@ -513,7 +522,7 @@ class Collection < ArvadosModel joins("JOIN collections ON links.head_uuid = collections.uuid"). order("links.created_at DESC") - docker_image_formats = Rails.configuration.Containers.SupportedDockerImageFormats + docker_image_formats = Rails.configuration.Containers.SupportedDockerImageFormats.keys.map(&:to_s) if (docker_image_formats.include? 'v1' and docker_image_formats.include? 'v2') or filter_compatible_format == false @@ -615,10 +624,10 @@ class Collection < ArvadosModel return end (managed_props.keys - self.properties.keys).each do |key| - if managed_props[key].has_key?('Value') - self.properties[key] = managed_props[key]['Value'] - elsif managed_props[key]['Function'].andand == 'original_owner' + if managed_props[key]['Function'] == 'original_owner' self.properties[key] = self.user_owner_uuid + elsif managed_props[key]['Value'] + self.properties[key] = managed_props[key]['Value'] else logger.warn "Unidentified default property definition '#{key}': #{managed_props[key].inspect}" end