Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion lib/astrails/safe/ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ def save
Net::FTP.open(host) do |ftp|
ftp.connect(host, port)
ftp.login(user, password)

dir = File.dirname(full_path)
parts = dir.split("/")
growing_path = ""
for part in parts
next if part == ""
if growing_path == ""
growing_path = part
else
growing_path = File.join(growing_path, part)
end
puts "Trying to create remote directory (#{growing_path})" if verbose?
begin
ftp.mkdir(growing_path)
rescue Net::FTPPermError
puts "Remote directory (#{growing_path}) exists, or no enough permissions" if verbose?
end
end

puts "Sending #{@backup.path} to #{full_path}" if verbose?
begin
ftp.put(@backup.path, full_path)
Expand Down Expand Up @@ -82,4 +101,4 @@ def port

end
end
end
end