lib/nexussw/lxd/transport/mixins/helpers/folder_txfr.rb in lxd-common-0.9.5 vs lib/nexussw/lxd/transport/mixins/helpers/folder_txfr.rb in lxd-common-0.9.6

- old
+ new

@@ -5,24 +5,24 @@ module LXD class Transport module Mixins module Helpers module FolderTxfr - def upload_folder(local_path, path, options = {}) - upload_using_tarball(local_path, path, options) || upload_files_individually(local_path, path, options) + def upload_folder(local_path, path) + upload_using_tarball(local_path, path) || upload_files_individually(local_path, path) end def download_folder(path, local_path, options = {}) download_using_tarball(path, local_path, options) || download_files_individually(path, local_path) end - def upload_files_individually(local_path, path, options = {}) + def upload_files_individually(local_path, path) dest = File.join(path, File.basename(local_path)) execute('mkdir -p ' + dest).error! # for parity with tarball extract Dir.entries(local_path).map { |f| (f == '.' || f == '..') ? nil : File.join(local_path, f) }.compact.each do |f| - upload_files_individually f, dest, options if File.directory? f - upload_file f, File.join(dest, File.basename(f)), options if File.file? f + upload_files_individually f, dest if File.directory? f + upload_file f, File.join(dest, File.basename(f)) if File.file? f end end def download_files_individually(path, local_path) dest = File.join(local_path, File.basename(path)) @@ -56,11 +56,11 @@ File.delete tarball_name if File.exist? tarball_name execute "rm -rf #{tfile}" end end - def upload_using_tarball(local_path, path, options = {}) + def upload_using_tarball(local_path, path) return false unless can_archive? begin tfile = Tempfile.new(container_name) tfile.close Transport.chdir_mutex.synchronize do @@ -68,10 +68,10 @@ Archive::Tar::Minitar.pack File.basename(local_path), Zlib::GzipWriter.new(File.open(tfile.path, 'wb')) end end # `tar -c#{flag}f #{tfile.path} -C #{File.dirname local_path} ./#{File.basename local_path}` fname = '/tmp/' + File.basename(tfile.path) + '.tgz' - upload_file tfile.path, fname, options + upload_file tfile.path, fname execute("bash -c 'mkdir -p #{path} && cd #{path} && tar -xf #{fname} && rm -rf #{fname}'").error! ensure tfile.unlink end