Merge branch 'master' into 3112-report-bug
[arvados.git] / services / api / app / models / collection.rb
index 2601a27a1a27d4da98bb683e3cc4bb9c143b2360..ac845f50adc71e5e95d4eded09779be72ffdca46 100644 (file)
@@ -6,10 +6,13 @@ class Collection < ArvadosModel
   api_accessible :user, extend: :common do |t|
     t.add :data_size
     t.add :files
+    t.add :manifest_text
   end
 
-  api_accessible :with_data, extend: :user do |t|
-    t.add :manifest_text
+  def self.attributes_required_columns
+    super.merge({ "data_size" => ["manifest_text"],
+                  "files" => ["manifest_text"],
+                })
   end
 
   def redundancy_status
@@ -164,11 +167,9 @@ class Collection < ArvadosModel
     if loc = Locator.parse(search_term)
       loc.strip_hints!
       coll_match = readable_by(*readers).where(uuid: loc.to_s).first
-      if coll_match.andand.files.andand.size == 1
-        dirname, basename = coll_match.files.first[0, 2]
-        if (dirname == ".") and (basename =~ /^[0-9A-Fa-f]{64}\.tar$/)
-          return [loc.to_s]
-        end
+      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