Skip to content

Commit f0bed92

Browse files
committed
Fixed base directory initialization
- The base directory is sometimes defined with a leading '/' that is not supported by the FTP server. This change tries to access the base directory without the leading '/' - If the base directory does not exist then we create it.
1 parent 6f19472 commit f0bed92

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

git-ftp.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,18 @@ def main():
145145
raise FtpSslNotSupported("Python is too old for FTP SSL. Try using Python 2.7 or later.")
146146
else:
147147
ftp = ftplib.FTP(options.ftp.hostname, options.ftp.username, options.ftp.password)
148-
ftp.cwd(base)
148+
try:
149+
ftp.cwd(base)
150+
except ftplib.error_perm:
151+
if base[0] == '/':
152+
try:
153+
ftp.cwd(base[1:])
154+
except ftplib.error_perm:
155+
ftp.mwd(base[1:])
156+
ftp.cwd(base[1:])
157+
else:
158+
ftp.mkd(base)
159+
ftp.cwd(base)
149160

150161
# Check revision
151162
hash = options.revision

0 commit comments

Comments
 (0)