修复编程单下发ftp路径

This commit is contained in:
jinling.yang
2024-06-26 11:10:54 +08:00
parent 1940116a35
commit 2ff935f68d
2 changed files with 10 additions and 11 deletions

View File

@@ -32,11 +32,11 @@ class FtpController():
for directory in directories:
if directory:
# 检查目录是否存在
if directory in ['NC']:
if (directory in ['NC']) or (directory not in ['home', 'ftp', 'ftp_root', 'NC']):
self.ftp.cwd(directory)
if directory not in ['home', 'ftp', 'ftp_root', 'NC']:
# 切换到新的目录
self.ftp.cwd(current_dir)
self.ftp.cwd(directory)
return os.path.basename(path)
except Exception as e:
logging.error(f"Error checking file: {e}")
@@ -60,14 +60,13 @@ class FtpController():
try:
logging.info('FTP目录:%s' % target_dir)
logging.info("进入FTP目录 ")
# self.ftp.cwd(target_dir) # 切换工作路径
# logging.info('FTP目录:%s' % target_dir)
remotenames = self.ftp.nlst()
logging.info('FTP目录文件:%s' % remotenames)
for file in remotenames:
server = os.path.join(serverdir, file)
if file.find(".pdf") != -1:
self.download_file(server, file)
return True
except:
return False