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_projects?
14 ApplicationController.helpers.human_readable_bytes_html(total_bytes) + " " + super
30 return [] if files.empty?
31 tree = files.group_by { |file_spec| File.split(file_spec.first) }
32 # Fill in entries for empty directories.
33 tree.keys.map { |basedir, _| File.split(basedir) }.each do |splitdir|
34 until tree.include?(splitdir)
36 splitdir = File.split(splitdir.first)
39 dir_to_tree = lambda do |dirname|
40 # First list subdirectories, with their files inside.
41 subnodes = tree.keys.select { |bd, td| (bd == dirname) and (td != '.') }
42 .sort.flat_map do |parts|
43 [parts + [nil]] + dir_to_tree.call(File.join(parts))
45 # Then extend that list with files in this directory.
46 subnodes + tree[File.split(dirname)]
51 def attribute_editable? attr, *args
60 arvados_api_client.api "collections/#{self.uuid}/", "provenance"
64 arvados_api_client.api "collections/#{self.uuid}/", "used_by"