lib/s3backup/manager.rb in s3backup-0.6.2 vs lib/s3backup/manager.rb in s3backup-0.6.3

- old
+ new

@@ -1,10 +1,11 @@ require 'cgi' require 'tempfile' require 'fileutils' require 's3backup/s3log' require 's3backup/tree_info' +require 's3backup/crypt' module S3backup class Manager DEFAULT_BUF_READ_SIZE=1024*1024*128 def initialize(target,config) @target = target @@ -36,19 +37,19 @@ Dir.foreach(dir) do |file| next if /^\.+$/ =~ file sub_dir.push(file) if File.directory?(dir+"/"+file) end exclude = "" - exclude = exclude + " --exclude=" + sub_dir.join(" --exclude=") if sub_dir.length != 0 - cmd = "(cd #{File.dirname(dir)};tar -czvf #{path} #{exclude} #{File.basename(dir)} > /dev/null 2>&1)" + exclude = exclude + " --exclude=" + sub_dir.map{|d| d.gsub(' ','\ ')}.join(" --exclude=") if sub_dir.length != 0 + cmd = "(cd #{File.dirname(dir).gsub(' ','\ ')};tar -czvf #{path.gsub(' ','\ ')} #{exclude} #{File.basename(dir).gsub(' ','\ ')} > /dev/null 2>&1)" S3log.debug(cmd) system(cmd) unless $?.success? raise "feiled #{cmd} execute. #{$?.inspect}" end end def from_tgz(path,dir) - cmd = "tar -xzvf #{path} -C #{dir} > /dev/null 2>&1" + cmd = "tar -xzvf #{path.gsub(' ','\ ')} -C #{dir.gsub(' ','\ ')} > /dev/null 2>&1" S3log.debug(cmd) system(cmd) unless $?.success? raise "feiled #{cmd} execute. #{$?.inspect}" end