lib/rmega/nodes/uploadable.rb in rmega-0.2.7 vs lib/rmega/nodes/uploadable.rb in rmega-0.3.1

- old
+ new

@@ -64,11 +64,11 @@ progress.increment(size) end end - pool.shutdown + pool.wait_done # encrypt attributes _attr = serialize_attributes(:n => Utils.utf8(::File.basename(path))) _attr = aes_cbc_encrypt(rnd_node_key.aes_key, _attr) @@ -82,9 +82,23 @@ ]) return Nodes::Factory.build(session, resp['f'][0]) ensure file.close if file + end + + def upload_dir(dir) + return create_folder(::File.basename(dir)).upload_dir(dir) unless name == ::File.basename(dir) + + ::Dir["#{dir}/*"].each do |path| + name = ::File.basename(path) + + if ::File.directory?(path) + create_folder(name).upload_dir(path) + elsif ::File.size(path) > 0 + upload(path) + end + end end end end end