From c749c42b4b91f361e57977d4070bd42158b7d742 Mon Sep 17 00:00:00 2001 From: robert00s Date: Sat, 20 May 2017 23:21:49 +0200 Subject: [PATCH] Fix #2667 --- frontend/apps/cloudstorage/ftp.lua | 2 +- frontend/apps/cloudstorage/ftpapi.lua | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/apps/cloudstorage/ftp.lua b/frontend/apps/cloudstorage/ftp.lua index 69c1f6ace..1c295270c 100644 --- a/frontend/apps/cloudstorage/ftp.lua +++ b/frontend/apps/cloudstorage/ftp.lua @@ -27,7 +27,7 @@ end function Ftp:run(address, user, pass, path) local url = generateUrl(address, user, pass) .. path - return FtpApi:listFolder(url) + return FtpApi:listFolder(url, path) end function Ftp:downloadFile(item, address, user, pass, path, close) diff --git a/frontend/apps/cloudstorage/ftpapi.lua b/frontend/apps/cloudstorage/ftpapi.lua index 58e51c627..8b6ff5c75 100644 --- a/frontend/apps/cloudstorage/ftpapi.lua +++ b/frontend/apps/cloudstorage/ftpapi.lua @@ -15,7 +15,7 @@ function FtpApi:nlst(u) return r and table.concat(t), e end -function FtpApi:listFolder(address_path) +function FtpApi:listFolder(address_path,folder_path) local ftp_list = {} local ftp_file = {} local type @@ -23,16 +23,18 @@ function FtpApi:listFolder(address_path) local file_name local ls_ftp = self:nlst(address_path) if ls_ftp == nil then return false end + if folder_path == "/" then + folder_path = "" + end for item in (ls_ftp..'\n'):gmatch'(.-)\r?\n' do if item ~= '' then file_name = item:match("([^/]+)$") extension = item:match("^.+(%..+)$") - item = "/" .. item if not extension then type = "folder" table.insert(ftp_list, { text = file_name .. "/", - url = item, + url = string.format("%s/%s",folder_path, file_name), type = type, }) --show only file with supported formats @@ -40,7 +42,7 @@ function FtpApi:listFolder(address_path) type = "file" table.insert(ftp_file, { text = file_name, - url = item, + url = string.format("%s/%s",folder_path, file_name), type = type, }) end