lib/bolt/executor.rb in bolt-2.20.0 vs lib/bolt/executor.rb in bolt-2.21.0
- old
+ new
@@ -320,10 +320,16 @@
end
end
def download_file(targets, source, destination, options = {})
description = options.fetch(:description, "file download from #{source} to #{destination}")
- FileUtils.mkdir_p(destination)
+
+ begin
+ FileUtils.mkdir_p(destination)
+ rescue Errno::EEXIST => e
+ message = "#{e.message}; unable to create destination directory #{destination}"
+ raise Bolt::Error.new(message, 'bolt/file-exist-error')
+ end
log_action(description, targets) do
options[:run_as] = run_as if run_as && !options.key?(:run_as)
batch_execute(targets) do |transport, batch|