lib/rmega/nodes/uploadable.rb in rmega-0.2.0 vs lib/rmega/nodes/uploadable.rb in rmega-0.2.1

- old
+ new

@@ -44,11 +44,11 @@ base_url = upload_url(filesize) pool = Pool.new read_mutex = Mutex.new - progress = Progress.new(filesize, caption: 'Upload') + progress = Progress.new(filesize, caption: 'Upload', filename: ::File.basename(path)) chunk_macs = {} self.class.each_chunk(filesize) do |start, size| pool.process do @@ -67,21 +67,19 @@ end pool.shutdown # encrypt attributes - attributes_str = "MEGA" - attributes_str << {n: ::File.basename(path)}.to_json - attributes_str << ("\x00" * (16 - (attributes_str.size % 16))) - encrypted_attributes = aes_cbc_encrypt(rnd_node_key.aes_key, attributes_str) + _attr = serialize_attributes(:n => ::File.basename(path)) + _attr = aes_cbc_encrypt(rnd_node_key.aes_key, _attr) # Calculate meta_mac file_mac = aes_cbc_mac(rnd_node_key.aes_key, chunk_macs.sort.map(&:last).join, "\x0"*16) rnd_node_key.meta_mac = Utils.compact_to_8_bytes(file_mac) encrypted_key = aes_ecb_encrypt(session.master_key, rnd_node_key.generate) resp = request(a: 'p', t: handle, n: [ - {h: file_handle, t: 0, a: Utils.base64urlencode(encrypted_attributes), k: Utils.base64urlencode(encrypted_key)} + {h: file_handle, t: 0, a: Utils.base64urlencode(_attr), k: Utils.base64urlencode(encrypted_key)} ]) return Nodes::Factory.build(session, resp['f'][0]) ensure file.close if file