basic-ftp
Advanced tools
Comparing version 3.4.2 to 3.4.3
# Changelog | ||
## 3.4.3 | ||
- Fixed: Handle multline response message closing without message. (#63) | ||
- Fixed: Track timeout during connect. (#64) | ||
## 3.4.2 | ||
@@ -4,0 +9,0 @@ |
@@ -203,7 +203,8 @@ "use strict"; | ||
this.passToHandler(err); | ||
return; | ||
} | ||
else if (command) { | ||
// Only track control socket timeout during the lifecycle of a task. This avoids timeouts on idle sockets, | ||
// the default socket behaviour which is not expected by most users. | ||
this.socket.setTimeout(this.timeout); | ||
// Only track control socket timeout during the lifecycle of a task. This avoids timeouts on idle sockets, | ||
// the default socket behaviour which is not expected by most users. | ||
this.socket.setTimeout(this.timeout); | ||
if (command) { | ||
this.send(command); | ||
@@ -210,0 +211,0 @@ } |
@@ -15,10 +15,11 @@ "use strict"; | ||
let startAt = 0; | ||
let token = ""; | ||
let tokenRegex; | ||
for (let i = 0; i < lines.length; i++) { | ||
const line = lines[i]; | ||
// No group has been opened. | ||
if (token === "") { | ||
if (!tokenRegex) { | ||
if (isMultiline(line)) { | ||
// Open a group by setting an expected token. | ||
token = line.substr(0, 3) + " "; | ||
const token = line.substr(0, 3); | ||
tokenRegex = new RegExp(`^${token}(?:$| )`); | ||
startAt = i; | ||
@@ -32,4 +33,4 @@ } | ||
// Group has been opened, expect closing token. | ||
else if (line.startsWith(token)) { | ||
token = ""; | ||
else if (tokenRegex.test(line)) { | ||
tokenRegex = undefined; | ||
messages.push(lines.slice(startAt, i + 1).join(LF)); | ||
@@ -39,3 +40,3 @@ } | ||
// The last group might not have been closed, report it as a rest. | ||
const rest = token !== "" ? lines.slice(startAt).join(LF) + LF : ""; | ||
const rest = tokenRegex ? lines.slice(startAt).join(LF) + LF : ""; | ||
return { messages, rest }; | ||
@@ -45,3 +46,3 @@ } | ||
function isSingle(line) { | ||
return /^\d\d\d /.test(line); | ||
return /^\d\d\d(?:$| )/.test(line); | ||
} | ||
@@ -48,0 +49,0 @@ function isMultiline(line) { |
{ | ||
"name": "basic-ftp", | ||
"version": "3.4.2", | ||
"version": "3.4.3", | ||
"description": "FTP client for Node.js, supports explicit FTPS over TLS, IPv6, Async/Await, and Typescript.", | ||
@@ -39,8 +39,8 @@ "main": "dist/index", | ||
"devDependencies": { | ||
"@types/node": "11.9.5", | ||
"@types/node": "11.10.4", | ||
"mocha": "6.0.2", | ||
"rimraf": "2.6.3", | ||
"tslint": "5.13.0", | ||
"tslint": "5.13.1", | ||
"typescript": "3.3.3333" | ||
} | ||
} |
@@ -67,3 +67,3 @@ # Basic FTP | ||
Close the client and all open socket connections. The client can’t be used anymore after calling this method, you have to either reconnect with `access` or `connect` or instantiate a new instance to continue any work. A client is also closed automatically if any timeout or connection error occurs. See the section on [Error Handling](#error-handling) below. | ||
Close the client and all open socket connections. The client can’t be used anymore after calling this method, you'll have to reconnect with `access` to continue any work. A client is also closed automatically if any timeout or connection error occurs. See the section on [Error Handling](#error-handling) below. | ||
@@ -192,3 +192,3 @@ `closed` | ||
This is different with a timeout or connection error: In addition to an `Error` being thrown, any connection to the FTP server will be closed. You’ll have to instantiate a new `Client` and reconnect, if you want to continue any work. | ||
This is different with a timeout or connection error: In addition to an `Error` being thrown, any connection to the FTP server will be closed. You’ll have to reconnect with `client.access()`, if you want to continue any work. | ||
@@ -195,0 +195,0 @@ ## Logging |
106172
2083