lib/rbbt/workflow/util/archive.rb in rbbt-util-5.26.119 vs lib/rbbt/workflow/util/archive.rb in rbbt-util-5.26.120

- old
+ new

@@ -47,11 +47,11 @@ end Log.debug "Archive finished at: #{target}" end end - def self.job_files_for_archive(files, relocate = false) + def self.job_files_for_archive(files, recursive = false) job_files = Set.new jobs = files.collect do |file| if Step === file file @@ -63,22 +63,21 @@ jobs.each do |step| next unless File.exists?(step.path) job_files << step.path job_files << step.info_file if File.exists?(step.info_file) - job_files << step.files_dir if Dir.glob(step.files_dir + '/*').any? + job_files << step.files_dir.glob("**") if Dir.glob(step.files_dir + '/*').any? rec_dependencies = Set.new + next unless recursive deps = [step.path] seen = Set.new while deps.any? path = deps.shift dep = Workflow.load_step path seen << dep.path - dep.relocated = !!relocate - dep.load_dependencies_from_info dep.dependencies.each do |dep| next if seen.include? dep.path deps << dep.path @@ -95,15 +94,15 @@ end job_files.to_a end - def self.archive(files, target = nil, relocate = true) + def self.archive(files, target = nil, recursive = true) target = self.path + '.tar.gz' if target.nil? target = File.expand_path(target) if String === target - job_files = job_files_for_archive files, relocate + job_files = job_files_for_archive files, recursive TmpFile.with_file do |tmpdir| job_files.each do |file| Step.link_job file, tmpdir end @@ -117,34 +116,38 @@ Log.debug "Archive finished at: #{target}" end end def self.migrate(path, search_path, options = {}) - resource=Rbbt other_rsync_args = options[:rsync] - relocate = options[:relocate] + recursive = options[:recursive] + recursive = false if recursive.nil? + paths = if options[:source] SSHDriver.run(options[:source], <<-EOF).split("\n") require 'rbbt-util' require 'rbbt/workflow' path = "#{path}" -relocate = #{ relocate.to_s } +recursive = #{ recursive.to_s } + if File.exists?(path) path = #{resource.to_s}.identify(path) else path = Path.setup(path) end + files = path.glob_all -if #{options[:recursive].to_s == 'true'} - files = Step.job_files_for_archive(files, relocate) -end + +files = Step.job_files_for_archive(files, recursive) + puts files * "\n" EOF + else if File.exists?(path) path = resource.identify(path) else path = Path.setup(path) @@ -153,10 +156,11 @@ if options[:recursive] files = Step.job_files_for_archive(files) end files end + iii paths target = if options[:target] target = SSHDriver.run(options[:target], <<-EOF).split("\n").first require 'rbbt-util' path = "var/jobs" @@ -216,12 +220,12 @@ end end end end - def self.purge(path, relocate = false) + def self.purge(path, recursive = false) path = [path] if String === path - job_files = job_files_for_archive path, relocate + job_files = job_files_for_archive path, recursive job_files.each do |file| begin Open.rm_rf file if Open.exists?(file) rescue