1 class Collection < ArvadosModel
4 include CommonApiTemplate
6 api_accessible :user, extend: :common do |t|
12 if redundancy_confirmed_as.nil?
14 elsif redundancy_confirmed_as < redundancy
17 if redundancy_confirmed_at.nil?
19 elsif Time.now - redundancy_confirmed_at < 7.days
28 if self.manifest_text.nil? and self.uuid.nil?
30 elsif self.manifest_text and self.uuid
31 if self.uuid.gsub(/\+[^,]+/,'') == Digest::MD5.hexdigest(self.manifest_text)
34 errors.add :uuid, 'uuid does not match checksum of manifest_text'
37 elsif self.manifest_text
38 errors.add :uuid, 'checksum for manifest_text not supplied in uuid'
41 errors.add :manifest_text, 'manifest_text not supplied'
47 inspect_manifest_text if @data_size.nil? or manifest_text_changed?
52 inspect_manifest_text if @files.nil? or manifest_text_changed?
56 def inspect_manifest_text
64 manifest_text.split("\n").each do |stream|
65 toks = stream.split(" ")
67 stream = toks[0].gsub /\\(\\|[0-7]{3})/ do |escape_sequence|
74 toks[1..-1].each do |tok|
75 if (re = tok.match /^[0-9a-f]{32}/)
77 tok.split('+')[1..-1].each do |hint|
78 if !blocksize and hint.match /^\d+$/
81 if (re = hint.match /^GS(\d+)$/)
82 blocksize = re[1].to_i
85 @data_size = false if !blocksize
86 @data_size += blocksize if @data_size
88 if (re = tok.match /^(\d+):(\d+):(\S+)$/)
89 filename = re[3].gsub /\\(\\|[0-7]{3})/ do |escape_sequence|
95 @files << [stream, filename, re[2].to_i]