Skip to content

Commit fc749b5

Browse files
committed
Displayed a more comprehensive error message if the base directory does not exist
Some FTP servers limit the access to a sub-directory of the filesystem while other FTP servers expose the entire filesystem and could also start the FTP session to the user home directory. In this case the base directory is related to the root filesystem and not related to the start of the TFP session. This error message highlights the given base directory and the directory where the FTP session started.
1 parent 6f19472 commit fc749b5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

git-ftp.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ 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+
raise ValueError("FTP base directory '%s' does not exist on this server (note: the server session starts at '%s')" % (base, ftp.pwd()))
149152

150153
# Check revision
151154
hash = options.revision

0 commit comments

Comments
 (0)