Permalink
Browse files

Added config.connection.debug_extras.print_ensure_folders

  • Loading branch information...
1 parent 0397c98 commit d72efcdb6a64bf538d24e8b62b6c688e4b957a62 @NoxArt committed Nov 12, 2012
Showing with 16 additions and 6 deletions.
  1. +2 −1 ftpsync.sublime-settings
  2. +14 −5 ftpsyncwrapper.py
View
3 ftpsync.sublime-settings
@@ -30,7 +30,8 @@
"debug_extras": {
"print_list_result": false,
- "dump_config_load": false
+ "dump_config_load": false,
+ "print_ensure_folders": false
}
},
View
19 ftpsyncwrapper.py
@@ -47,6 +47,9 @@
# error code - first 3-digit number https://tools.ietf.org/html/rfc959#page-39
re_errorCode = re.compile("[1-5]\d\d")
+# 20x ok code
+re_errorOk = re.compile("2\d\d");
+
# For FTP LIST entries with {last modified} timestamp earlier than 6 months, see http://stackoverflow.com/questions/2443007/ftp-list-format
currentYear = int(time.strftime("%Y", time.gmtime()))
@@ -245,7 +248,7 @@ def action():
self.connection.storbinary(command, uploaded)
except Exception, e:
if self.__isErrorCode(e, ['ok', 'passive']) is True:
- self.connection.storbinary(command, uploaded)
+ pass
elif self.__isErrorCode(e, 'fileUnavailible') and failed is False:
self.__ensurePath(path)
self.put(file_path, new_name, True)
@@ -447,7 +450,9 @@ def __execute(self, callback):
except Exception, e:
# bad write - repeat command
- if str(e).find(sslErrors['badWrite']) is True:
+ if re_errorOk.search(str(e)) is not None:
+ return
+ elif str(e).find(sslErrors['badWrite']) is True:
return callback()
# disconnected - close itself to be refreshed
elif self.__isError(e, 'disconnected') is True:
@@ -534,9 +539,11 @@ def __ensurePath(self, path, isFolder=False):
self.connection.cwd(self.config['path'])
relative = os.path.relpath(path, self.config['path'])
+ relative = self._postprocessPath(relative)
- folders = self._postprocessPath(relative)
- folders = folders.split("/")
+ folders = relative.split("/")
+ if self.config['debug_extras']['print_ensure_folders'] is True:
+ print relative, folders
index = 0
for folder in folders:
@@ -553,7 +560,7 @@ def __ensurePath(self, path, isFolder=False):
self.connection.mkd(folder)
except Exception, e:
if self.__isErrorCode(e, 'fileUnavailible'):
- # exists, but not proper permissions
+ # not proper permissions
self.chmod(folder, self.config['default_folder_permissions'])
else:
raise
@@ -563,5 +570,7 @@ def __ensurePath(self, path, isFolder=False):
else:
raise
+ self.connection.cwd(self.config['path'])
+
#class SSHConnection():

0 comments on commit d72efcd

Please sign in to comment.