Skip to content
This repository has been archived by the owner on Jun 20, 2021. It is now read-only.

Commit

Permalink
fixed folder creation when creating several tree levels at once
Browse files Browse the repository at this point in the history
  • Loading branch information
felipesabino committed Dec 11, 2012
1 parent aa71c9b commit ec37854
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/shenzhen/plugins/ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ def upload_build(files, options)
@connection.login(@user, @pass) rescue raise "Login authentication failed"

if options[:mkdir]
begin
@connection.mkdir @ftp_path
rescue => exception
if !exception.to_s.match(/File exists/)
raise "Can not create folder \"#{@ftp_path}\". FTP exception: #{exception}"
paths = @ftp_path.split('/')
(1..paths.size).each do |i|
begin
path = paths.slice(0,i).join('/')
next if path == ""
@connection.mkdir path
rescue => exception
if !exception.to_s.match(/File exists/)
raise "Can not create folder \"#{path}\". FTP exception: #{exception}"
end
end
end
end
Expand Down

0 comments on commit ec37854

Please sign in to comment.