X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/251cc49d99c14d28942636fbcef9515bd39c9575..3280e2dc5fd16dca63c389b931658d4420faabaf:/sdk/ruby/lib/arvados/keep.rb diff --git a/sdk/ruby/lib/arvados/keep.rb b/sdk/ruby/lib/arvados/keep.rb index d966727de9..e4f62083b0 100644 --- a/sdk/ruby/lib/arvados/keep.rb +++ b/sdk/ruby/lib/arvados/keep.rb @@ -138,11 +138,14 @@ module Keep def split_file_token token start_pos, filesize, filename = token.split(':', 3) - [start_pos.to_i, filesize.to_i, filename] + if filename.nil? + raise ArgumentError.new "Invalid file token '#{token}'" + end + [start_pos.to_i, filesize.to_i, unescape(filename)] end def each_file_spec - return to_enum(__method__, speclist) unless block_given? + return to_enum(__method__) unless block_given? @text.each_line do |line| stream_name = nil in_file_tokens = false @@ -188,6 +191,11 @@ module Keep seen_files.size end + def files_size + # Return the total size of all files in this manifest. + files.reduce(0) { |total, (_, _, size)| total + size } + end + def exact_file_count?(want_count) files_count(want_count + 1) == want_count end