3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/boatman/copyable.rb', line 3
def copy(file, params, remove_original=false, &block)
source_path = file.path
base_name = params[:rename] || FTPUtils::FTPFile.basename(source_path)
destination_path = FTPUtils::FTPFile.expand_path(params[:to] + "/" + base_name)
return if FTPUtils::FTPFile.exists?(destination_path)
begin
copy_entry(source_path, destination_path, &block)
FTPUtils.rm_r source_path if remove_original
Boatman.logger.info "Successfully copied #{source_path} to #{destination_path}"
rescue Exception => e
FTPUtils.rm_r "#{destination_path}" rescue nil
Boatman.logger.error "#{e.message} at #{e.backtrace[0]}"
end
end
|