diff options
Diffstat (limited to 'src/ftp.lua')
-rw-r--r-- | src/ftp.lua | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/ftp.lua b/src/ftp.lua index 72be695..842fdbb 100644 --- a/src/ftp.lua +++ b/src/ftp.lua | |||
@@ -13,6 +13,7 @@ local socket = _G[LUASOCKET_LIBNAME] | |||
13 | -- require other modules | 13 | -- require other modules |
14 | require("ltn12") | 14 | require("ltn12") |
15 | require("url") | 15 | require("url") |
16 | require("tp") | ||
16 | 17 | ||
17 | -- create namespace inside LuaSocket namespace | 18 | -- create namespace inside LuaSocket namespace |
18 | socket.ftp = socket.ftp or {} | 19 | socket.ftp = socket.ftp or {} |
@@ -101,7 +102,9 @@ function metat.__index:send(sendt) | |||
101 | local data | 102 | local data |
102 | socket.try(self.pasvt or self.portt, "need port or pasv first") | 103 | socket.try(self.pasvt or self.portt, "need port or pasv first") |
103 | if self.pasvt then data = socket.try(pasv(self.pasvt)) end | 104 | if self.pasvt then data = socket.try(pasv(self.pasvt)) end |
104 | socket.try(self.tp:command(sendt.command or "stor", sendt.argument)) | 105 | local argument = sendt.argument or string.gsub(sendt.path, "^/", "") |
106 | local command = sendt.command or "stor" | ||
107 | socket.try(self.tp:command(command, argument)) | ||
105 | local code, reply = socket.try(self.tp:check{"2..", "1.."}) | 108 | local code, reply = socket.try(self.tp:check{"2..", "1.."}) |
106 | if self.portt then data = socket.try(port(self.portt)) end | 109 | if self.portt then data = socket.try(port(self.portt)) end |
107 | local step = sendt.step or ltn12.pump.step | 110 | local step = sendt.step or ltn12.pump.step |
@@ -128,7 +131,9 @@ function metat.__index:receive(recvt) | |||
128 | local data | 131 | local data |
129 | socket.try(self.pasvt or self.portt, "need port or pasv first") | 132 | socket.try(self.pasvt or self.portt, "need port or pasv first") |
130 | if self.pasvt then data = socket.try(pasv(self.pasvt)) end | 133 | if self.pasvt then data = socket.try(pasv(self.pasvt)) end |
131 | socket.try(self.tp:command(recvt.command or "retr", recvt.argument)) | 134 | local argument = recvt.argument or string.gsub(recvt.path, "^/", "") |
135 | local command = recvt.command or "retr" | ||
136 | socket.try(self.tp:command(command, argument)) | ||
132 | local code = socket.try(self.tp:check{"1..", "2.."}) | 137 | local code = socket.try(self.tp:check{"1..", "2.."}) |
133 | if self.portt then data = socket.try(port(self.portt)) end | 138 | if self.portt then data = socket.try(port(self.portt)) end |
134 | local source = socket.source("until-closed", data) | 139 | local source = socket.source("until-closed", data) |
@@ -200,8 +205,6 @@ local function parse(url) | |||
200 | putt.type = socket.skip(2, string.find(putt.params, pat)) | 205 | putt.type = socket.skip(2, string.find(putt.params, pat)) |
201 | socket.try(putt.type == "a" or putt.type == "i") | 206 | socket.try(putt.type == "a" or putt.type == "i") |
202 | end | 207 | end |
203 | -- skip first backslash in path | ||
204 | putt.argument = string.sub(putt.path, 2) | ||
205 | return putt | 208 | return putt |
206 | end | 209 | end |
207 | 210 | ||