Hide ftp.PORT "constant" as a local

This commit is contained in:
Diego Nehab 2016-03-07 01:33:08 -03:00
parent 916b548240
commit 23ce5aeaa2
2 changed files with 2 additions and 3 deletions

View File

@ -86,7 +86,6 @@ the FTP module:
<ul>
<li> <tt>PASSWORD</tt>: default anonymous password.
<li> <tt>PORT</tt>: default port used for the control connection;
<li> <tt>TIMEOUT</tt>: sets the timeout for all I/O operations;
<li> <tt>USER</tt>: default anonymous user;
</ul>

View File

@ -23,7 +23,7 @@ local _M = socket.ftp
-- timeout in seconds before the program gives up on a connection
_M.TIMEOUT = 60
-- default port for ftp service
_M.PORT = 21
local PORT = 21
-- this is the default anonymous password. used when no password is
-- provided in url. should be changed to your e-mail.
_M.USER = "ftp"
@ -35,7 +35,7 @@ _M.PASSWORD = "anonymous@anonymous.org"
local metat = { __index = {} }
function _M.open(server, port, create)
local tp = socket.try(tp.connect(server, port or _M.PORT, _M.TIMEOUT, create))
local tp = socket.try(tp.connect(server, port or PORT, _M.TIMEOUT, create))
local f = base.setmetatable({ tp = tp }, metat)
-- make sure everything gets closed in an exception
f.try = socket.newtry(function() f:close() end)