1 class Collection < ArvadosBase
2 MD5_EMPTY = 'd41d8cd98f00b204e9800998ecf8427e'
4 # Return true if the given string is the locator of a zero-length blob
5 def self.is_empty_blob_locator? locator
6 !!locator.to_s.match("^#{MD5_EMPTY}(\\+.*)?\$")
9 def self.goes_in_folders?
14 ApplicationController.helpers.human_readable_bytes_html(total_bytes) + " " + super
28 return [] if files.empty?
29 tree = files.group_by { |file_spec| File.split(file_spec.first) }
30 # Fill in entries for empty directories.
31 tree.keys.map { |basedir, _| File.split(basedir) }.each do |splitdir|
32 until tree.include?(splitdir)
34 splitdir = File.split(splitdir.first)
37 dir_to_tree = lambda do |dirname|
38 # First list subdirectories, with their files inside.
39 subnodes = tree.keys.select { |bd, td| (bd == dirname) and (td != '.') }
40 .sort.flat_map do |parts|
41 [parts + [nil]] + dir_to_tree.call(File.join(parts))
43 # Then extend that list with files in this directory.
44 subnodes + tree[File.split(dirname)]
49 def attribute_editable? attr, *args
58 arvados_api_client.api "collections/#{self.uuid}/", "provenance"
62 arvados_api_client.api "collections/#{self.uuid}/", "used_by"