class Rmega::Storage
Attributes
session[R]
Public Class Methods
new(session)
click to toggle source
# File lib/rmega/storage.rb, line 14 def initialize(session) @session = session end
Public Instance Methods
nodes()
click to toggle source
# File lib/rmega/storage.rb, line 46 def nodes return @nodes if @nodes results = session.request(a: 'f', c: 1) (results['ok'] || []).each do |hash| shared_keys[hash['h']] ||= aes_ecb_decrypt(master_key, Utils.base64urldecode(hash['k'])) end (results['f'] || []).map do |node_data| node = Nodes::Factory.build(session, node_data) node.process_shared_key if node.shared_root? node end end
nodes=(list)
click to toggle source
# File lib/rmega/storage.rb, line 42 def nodes=(list) @nodes = list end
quota()
click to toggle source
# File lib/rmega/storage.rb, line 38 def quota session.request(a: 'uq', strg: 1) end
root()
click to toggle source
# File lib/rmega/storage.rb, line 70 def root @root ||= nodes.find { |n| n.type == :root } end
stats()
click to toggle source
# File lib/rmega/storage.rb, line 26 def stats stats_hash = {files: 0, size: 0} nodes.each do |n| next unless n.type == :file stats_hash[:files] += 1 stats_hash[:size] += n.filesize end return stats_hash end
total_space()
click to toggle source
# File lib/rmega/storage.rb, line 22 def total_space quota['mstrg'] end
trash()
click to toggle source
# File lib/rmega/storage.rb, line 66 def trash @trash ||= nodes.find { |n| n.type == :trash } end
used_space()
click to toggle source
# File lib/rmega/storage.rb, line 18 def used_space quota['cstrg'] end