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}(\\+.*)?\$")
12 human_readable_bytes_html(total_bytes) + " " + super
26 tree = files.group_by { |file_spec| File.split(file_spec.first) }
27 # Fill in entries for empty directories.
28 tree.keys.map { |basedir, _| File.split(basedir) }.each do |splitdir|
29 until tree.include?(splitdir)
31 splitdir = File.split(splitdir.first)
34 dir_to_tree = lambda do |dirname|
35 # First list subdirectories, with their files inside.
36 subnodes = tree.keys.select { |bd, td| (bd == dirname) and (td != '.') }
37 .sort.flat_map do |parts|
38 [parts + [nil]] + dir_to_tree.call(File.join(parts))
40 # Then extend that list with files in this directory.
41 subnodes + tree[File.split(dirname)]
46 def attribute_editable?(attr)
55 arvados_api_client.api "collections/#{self.uuid}/", "provenance"
59 arvados_api_client.api "collections/#{self.uuid}/", "used_by"