Permalink
Browse files

fix a nested folders bug in ftp.upload_dir

  • Loading branch information...
1 parent e6c9b25 commit f94871a564274625768f2da63507d120232ca717 @zrong committed Jun 6, 2016
Showing with 9 additions and 8 deletions.
  1. +1 −1 rookout/__init__.py
  2. +8 −7 rookout/ftp.py
View
@@ -15,7 +15,7 @@
import logging
import sys
-__version__ = "0.5.0"
+__version__ = "0.5.1"
__all__ = ['base', 'git', 'lua', 'ftp', 'gettext', 'conf']
slog = logging.getLogger("system")
View
@@ -95,18 +95,19 @@ def upload_dir(dir_name, upload_dir, ftp_conf):
ftp.mkd(dir_name)
ftp.cwd(dir_name)
slog.info('Uploading "%s" to "%s/%s" ......'%(upload_dir, ftpStr, dir_name))
- subDirs = ftp.nlst()
- rootLen = len(upload_dir)+1
+ rootLen = len(upload_dir) + 1
+
for r,d,fl in os.walk(upload_dir):
if r.split('/')[-1].startswith('.'):
continue
for sdir in d:
- if not sdir.startswith('.') \
- and sdir not in subDirs:
- dirPath = os.path.join(r, sdir)[rootLen:]
- ftp.mkd(dirPath)
+ if not sdir.startswith('.'):
+ dirPath = r[rootLen:]
+ if sdir not in ftp.nlst(dirPath):
+ dir_name = os.path.join(dirPath, sdir)
+ ftp.mkd(dir_name)
for sf in fl:
- filePath = os.path.join(r, sf)
+ filePath = os.path.join(r, sf)
f = open(filePath, 'rb')
ftpPath = filePath[rootLen:]
slog.info('%s -> %s', filePath, ftpPath)

0 comments on commit f94871a

Please sign in to comment.