X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/a15f61aef5f26dc6d0bb3e6ab02428b1d2a87ae8..6ba24a89c7b2fa6f600910dc28af218500a463dd:/services/api/app/models/collection.rb diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb index a50c47b6a3..ee3b29c5bd 100644 --- a/services/api/app/models/collection.rb +++ b/services/api/app/models/collection.rb @@ -12,6 +12,12 @@ class Collection < ArvadosModel t.add :manifest_text end + def self.attributes_required_columns + super.merge({ "data_size" => ["manifest_text"], + "files" => ["manifest_text"], + }) + end + def redundancy_status if redundancy_confirmed_as.nil? 'unconfirmed' @@ -159,12 +165,15 @@ class Collection < ArvadosModel joins("JOIN collections ON links.head_uuid = collections.uuid"). order("links.created_at DESC") - # If the search term is a Collection locator with an associated - # Docker image hash link, return that Collection. - coll_matches = base_search. - where(link_class: "docker_image_hash", collections: {uuid: search_term}) - if match = coll_matches.first - return [match.head_uuid] + # If the search term is a Collection locator that contains one file + # that looks like a Docker image, return it. + if loc = Locator.parse(search_term) + loc.strip_hints! + coll_match = readable_by(*readers).where(uuid: loc.to_s).first + if coll_match and (coll_match.files.size == 1) and + (coll_match.files[0][1] =~ /^[0-9A-Fa-f]{64}\.tar$/) + return [loc.to_s] + end end # Find Collections with matching Docker image repository+tag pairs.