lib/rmega/storage.rb in rmega-0.0.3 vs lib/rmega/storage.rb in rmega-0.0.4

- old
+ new

@@ -25,15 +25,15 @@ def quota session.request a: 'uq', strg: 1 end - # Nodes finders + # Nodes management def nodes nodes = session.request a: 'f', c: 1 - nodes['f'].map { |node_data| Node.new(session, node_data) } + nodes['f'].map { |node_data| Node.fabricate(session, node_data) } end def nodes_by_type type nodes.select { |n| n.type == type } end @@ -50,11 +50,15 @@ def root_node @root_node ||= nodes_by_type(:root).first end + def create_folder parent_node, folder_name + FolderNode.create session, parent_node, folder_name + end + # Handle node download def self.chunks size list = {} p = 0 @@ -99,10 +103,10 @@ def upload local_path, parent_node = root_node local_path = File.expand_path local_path filesize = File.size local_path upld_url = upload_url filesize - ul_key = Array.new(6).map { rand(0..0xFFFFFFFF) } + ul_key = Crypto.random_key aes_key = ul_key[0..3] nonce = ul_key[4..5] local_file = File.open local_path, 'rb' file_handle = nil file_mac = [0, 0, 0, 0]