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