diff --git a/src/Client.ts b/src/Client.ts index f80e199..3579c0d 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -49,8 +49,8 @@ export interface UploadOptions { localEndInclusive?: number } -const LIST_COMMANDS_DEFAULT: readonly string[] = ["LIST -a", "LIST"] -const LIST_COMMANDS_MLSD: readonly string[] = ["MLSD", "LIST -a", "LIST"] +const LIST_COMMANDS_DEFAULT = () => ["LIST -a", "LIST"] +const LIST_COMMANDS_MLSD = () => ["MLSD", "LIST -a", "LIST"] /** * High-level API to interact with an FTP server. @@ -58,7 +58,7 @@ const LIST_COMMANDS_MLSD: readonly string[] = ["MLSD", "LIST -a", "LIST"] export class Client { prepareTransfer: TransferStrategy parseList: RawListParser - availableListCommands = LIST_COMMANDS_DEFAULT.slice() + availableListCommands = LIST_COMMANDS_DEFAULT() /** Low-level API to interact with FTP server. */ readonly ftp: FTPContext /** Tracks progress of data transfers. */ @@ -234,7 +234,7 @@ export class Client { // Use MLSD directory listing if possible. See https://tools.ietf.org/html/rfc3659#section-7.8: // "The presence of the MLST feature indicates that both MLST and MLSD are supported." const supportsMLSD = features.has("MLST") - this.availableListCommands = supportsMLSD ? LIST_COMMANDS_MLSD.slice() : LIST_COMMANDS_DEFAULT.slice() + this.availableListCommands = supportsMLSD ? LIST_COMMANDS_MLSD() : LIST_COMMANDS_DEFAULT() await this.send("TYPE I") // Binary mode await this.sendIgnoringError("STRU F") // Use file structure await this.sendIgnoringError("OPTS UTF8 ON") // Some servers expect UTF-8 to be enabled explicitly and setting before login might not have worked.