ssh2-sftp-client 9.0.0 → 9.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,65 +1,65 @@
1
- - [Overview](#orgdb4a63c)
2
- - [Version 9.x Changes](#org3c3e874)
3
- - [Installation](#orga783863)
4
- - [Basic Usage](#org2f471c4)
5
- - [Documentation](#orgb5102f6)
6
- - [Specifying Paths](#orgdae808e)
7
- - [Methods](#orga8e09d8)
8
- - [new SftpClient(name) ===> SFTP client object](#org518d51a)
9
- - [connect(config) ===> SFTP object](#orgda648f9)
10
- - [list(path, filter) ==> Array[object]](#org3258731)
11
- - [exists(path) ==> boolean](#orgaae7860)
12
- - [stat(path) ==> object](#org1e4f14a)
13
- - [get(path, dst, options) ==> String|Stream|Buffer](#org447f36c)
14
- - [fastGet(remotePath, localPath, options) ===> string](#org54de461)
15
- - [put(src, remotePath, options) ==> string](#orgee0d1ef)
16
- - [fastPut(localPath, remotePath, options) ==> string](#orgb9d8ee2)
17
- - [append(input, remotePath, options) ==> string](#org1eaae65)
18
- - [mkdir(path, recursive) ==> string](#org1c3ab90)
19
- - [rmdir(path, recursive) ==> string](#org003ef11)
20
- - [delete(path, noErrorOK) ==> string](#orgd3e3a35)
21
- - [rename(fromPath, toPath) ==> string](#org3343888)
22
- - [posixRename(fromPath, toPath) ==> string](#orgb8f840c)
23
- - [chmod(path, mode) ==> string](#org15551c9)
24
- - [realPath(path) ===> string](#org4ec95c3)
25
- - [cwd() ==> string](#orgc1265f0)
26
- - [uploadDir(srcDir, dstDir, options) ==> string](#org5c10c06)
27
- - [downloadDir(srcDir, dstDir, options) ==> string](#org614dc71)
28
- - [createReadStream(remotePath, options)) ==> stream object](#org906505f)
29
- - [createWriteStream(remotePath, options) ==> stream object](#orgf5b3858)
30
- - [rcopy(srcPath, dstPath) ==> string](#org3716ce1)
31
- - [end() ==> boolean](#org93bfcf3)
32
- - [Add and Remove Listeners](#org8fe6c29)
33
- - [Platform Quirks & Warnings](#org763e7bf)
34
- - [Server Capabilities](#org3c7ec29)
35
- - [Promises, Events & Managing Exceptions](#org13e7f16)
36
- - [Adding Custom Handlers](#orgbea2ca0)
37
- - [Windows Based Servers](#org13d5c2b)
38
- - [Don't Re-use SftpClient Objects](#org56317e1)
39
- - [FAQ](#orgb28c841)
40
- - [Remote server drops connections with only an end event](#orgb4c1c9d)
41
- - [How can I pass writable stream as dst for get method?](#orgf09bf16)
42
- - [How can I upload files without having to specify a password?](#org10382e7)
43
- - [How can I connect through a Socks Proxy](#org34d3eb7)
44
- - [Timeout while waiting for handshake or handshake errors](#orgbe4be79)
45
- - [How can I limit upload/download speed](#org36a1f06)
46
- - [Connection hangs or fails for larger files](#org293ce0b)
47
- - [Examples](#org897888b)
48
- - [Troubleshooting](#orgd93090a)
49
- - [Common Errors](#org44294d4)
50
- - [Not returning the promise in a `then()` block](#org44783ba)
51
- - [Mixing Promise Chains and Async/Await](#org1bee008)
52
- - [Try/catch and Error Handlers](#org004696d)
53
- - [Server Differences](#org9131050)
54
- - [Avoid Concurrent Operations](#org6c9fbb1)
55
- - [Debugging Support](#org52099c1)
56
- - [Logging Issues](#orga96ad01)
57
- - [Pull Requests](#org0fa18ba)
58
- - [Contributors](#org05880d2)
59
-
60
-
61
-
62
- <a id="orgdb4a63c"></a>
1
+ - [Overview](#org19c31e8)
2
+ - [Version 9.x Changes](#orgc330d84)
3
+ - [Installation](#org7c63f6a)
4
+ - [Basic Usage](#orgb99a07c)
5
+ - [Documentation](#org5550f37)
6
+ - [Specifying Paths](#org2f0a3a6)
7
+ - [Methods](#org8d230d5)
8
+ - [new SftpClient(name) ===> SFTP client object](#orgc8b55d7)
9
+ - [connect(config) ===> SFTP object](#org42512fb)
10
+ - [list(path, filter) ==> Array[object]](#orgbe9e165)
11
+ - [exists(path) ==> boolean](#org14dee5e)
12
+ - [stat(path) ==> object](#orga0033c0)
13
+ - [get(path, dst, options) ==> String|Stream|Buffer](#org02a3dc5)
14
+ - [fastGet(remotePath, localPath, options) ===> string](#orge9f875d)
15
+ - [put(src, remotePath, options) ==> string](#orgc7941ea)
16
+ - [fastPut(localPath, remotePath, options) ==> string](#org8f8794d)
17
+ - [append(input, remotePath, options) ==> string](#org82c75b5)
18
+ - [mkdir(path, recursive) ==> string](#org42c5eeb)
19
+ - [rmdir(path, recursive) ==> string](#orgd0aa59d)
20
+ - [delete(path, noErrorOK) ==> string](#orgb496048)
21
+ - [rename(fromPath, toPath) ==> string](#org1a2be8f)
22
+ - [posixRename(fromPath, toPath) ==> string](#org571c0b9)
23
+ - [chmod(path, mode) ==> string](#org02d64a4)
24
+ - [realPath(path) ===> string](#org008d567)
25
+ - [cwd() ==> string](#org7033d28)
26
+ - [uploadDir(srcDir, dstDir, options) ==> string](#orgfa0102a)
27
+ - [downloadDir(srcDir, dstDir, options) ==> string](#orgefe6fc6)
28
+ - [createReadStream(remotePath, options)) ==> stream object](#org783e363)
29
+ - [createWriteStream(remotePath, options) ==> stream object](#orgf45313d)
30
+ - [rcopy(srcPath, dstPath) ==> string](#orga31c8c1)
31
+ - [end() ==> boolean](#org4d02fde)
32
+ - [Add and Remove Listeners](#orge5769d3)
33
+ - [Platform Quirks & Warnings](#org3e6ddf9)
34
+ - [Server Capabilities](#org61f0fe5)
35
+ - [Promises, Events & Managing Exceptions](#orga7d6067)
36
+ - [Adding Custom Handlers](#orgc08d427)
37
+ - [Windows Based Servers](#org5439468)
38
+ - [Don't Re-use SftpClient Objects](#orgae9129c)
39
+ - [FAQ](#org3761660)
40
+ - [Remote server drops connections with only an end event](#org1e669d1)
41
+ - [How can I pass writable stream as dst for get method?](#org71d5bab)
42
+ - [How can I upload files without having to specify a password?](#orgaafc964)
43
+ - [How can I connect through a Socks Proxy](#orgebf85e2)
44
+ - [Timeout while waiting for handshake or handshake errors](#org528d9ea)
45
+ - [How can I limit upload/download speed](#org3b6ff20)
46
+ - [Connection hangs or fails for larger files](#orgb5e285f)
47
+ - [Examples](#org18ce0c2)
48
+ - [Troubleshooting](#orgf4b6c80)
49
+ - [Common Errors](#orga419582)
50
+ - [Not returning the promise in a `then()` block](#orgd5f3557)
51
+ - [Mixing Promise Chains and Async/Await](#org557d1c5)
52
+ - [Try/catch and Error Handlers](#org2bf9a3a)
53
+ - [Server Differences](#org89795d7)
54
+ - [Avoid Concurrent Operations](#orgbec08b0)
55
+ - [Debugging Support](#org124cfc9)
56
+ - [Logging Issues](#org5f3c941)
57
+ - [Pull Requests](#org6e82efc)
58
+ - [Contributors](#org680b5c2)
59
+
60
+
61
+
62
+ <a id="org19c31e8"></a>
63
63
 
64
64
  # Overview
65
65
 
@@ -67,17 +67,18 @@ an SFTP client for node.js, a wrapper around [SSH2](https://github.com/mscdex/ss
67
67
 
68
68
  Documentation on the methods and available options in the underlying modules can be found on the [SSH2](https://github.com/mscdex/ssh2) project pages.
69
69
 
70
- Current stable release is **v9.0.0**.
70
+ Current stable release is **v9.0.1**.
71
71
 
72
72
  Code has been tested against Node versions 14.19.1, 16.15.0 and 18.1.0
73
73
 
74
- Node versions < 12.x are not supported. However, node v10.x should still work, although some tests will fail due to changes in file system functions used in test setup and tear down.
74
+ Node versions < 14.x are not supported.
75
75
 
76
76
 
77
- <a id="org3c3e874"></a>
77
+ <a id="orgc330d84"></a>
78
78
 
79
79
  ## Version 9.x Changes
80
80
 
81
+ - **Breaking Change**: This version uses syntax not supported in node versions prior to v14. Therefore, node versions less than v14 will not work.
81
82
  - **Breaking Change**: This `list()` method no longer accepts a regular expression for filtering the entries to be returned. You can now specify a filter function instead. The function is called for each item in the list of items to be returned, passing in the item object as its only argument. Essentially, this is just a call to `Array.filter()`, so the filter function should behave in the same way i.e. return true for items to be retained and false for those to be dropped.
82
83
  - **Breaking Change**: The ability to set `autoClose` on read and write streams and the ability to set `end` on `pipe` operations has been removed. These options caused confusion for users and were too easy to get wrong, plus it made the methods overly complicated. For those use-cases where you want to control streams at a low level, two new methods have been added, `createReadStream()` and `createWriteStream()`. However, it should be noted that client code is 100% responsible for managing streams obtained using these methods. Use at your own risk!
83
84
  - **Breaking Change**: The 3rd argument to `uploadDir()` and `downloadDir()` methods has been change. Previously, the argument was a filter function used to select which directories and files to be transferred. The 3rd argument is now an options object with two supported properties, `filter` and `useFastput` (for `uploadDir()`) or `useFastget` (for `downloadDir()`). If `useFastput` is true, the `fastPut()` method will be pused to upload files. If `false` or missing, the slower, but better supported, `put()` method will be used. Likewise, the `useFastget` options can be set to `true` to use the `fastGet()` method for donwloading files, otherwise the slower, but more reliable, `get()` method will be used.
@@ -88,7 +89,7 @@ Node versions < 12.x are not supported. However, node v10.x should still work, a
88
89
  - Bumped ssh2 version to 1.11.0
89
90
 
90
91
 
91
- <a id="orga783863"></a>
92
+ <a id="org7c63f6a"></a>
92
93
 
93
94
  # Installation
94
95
 
@@ -97,7 +98,7 @@ npm install ssh2-sftp-client
97
98
  ```
98
99
 
99
100
 
100
- <a id="org2f471c4"></a>
101
+ <a id="orgb99a07c"></a>
101
102
 
102
103
  # Basic Usage
103
104
 
@@ -120,7 +121,7 @@ sftp.connect({
120
121
  ```
121
122
 
122
123
 
123
- <a id="orgb5102f6"></a>
124
+ <a id="org5550f37"></a>
124
125
 
125
126
  # Documentation
126
127
 
@@ -129,7 +130,7 @@ The connection options are the same as those offered by the underlying SSH2 modu
129
130
  All the methods will return a Promise, except for `on()` and `removeListener()`, which are typically only used in special use cases.
130
131
 
131
132
 
132
- <a id="orgdae808e"></a>
133
+ <a id="org2f0a3a6"></a>
133
134
 
134
135
  ## Specifying Paths
135
136
 
@@ -162,12 +163,12 @@ client.put('/home/fred/test.txt', '/remote/dir/test-copy.txt');
162
163
  This will copy the local file `test.txt` to the remote file `test-copy.txt` in the directory `/remote/dir`.
163
164
 
164
165
 
165
- <a id="orga8e09d8"></a>
166
+ <a id="org8d230d5"></a>
166
167
 
167
168
  ## Methods
168
169
 
169
170
 
170
- <a id="org518d51a"></a>
171
+ <a id="orgc8b55d7"></a>
171
172
 
172
173
  ### new SftpClient(name) ===> SFTP client object
173
174
 
@@ -206,7 +207,7 @@ Constructor to create a new `ssh2-sftp-client` object. An optional `name` string
206
207
  ```
207
208
 
208
209
 
209
- <a id="orgda648f9"></a>
210
+ <a id="org42512fb"></a>
210
211
 
211
212
  ### connect(config) ===> SFTP object
212
213
 
@@ -272,7 +273,7 @@ Connect to an sftp server. Full documentation for connection options is availabl
272
273
  ```
273
274
 
274
275
 
275
- <a id="org3258731"></a>
276
+ <a id="orgbe9e165"></a>
276
277
 
277
278
  ### list(path, filter) ==> Array[object]
278
279
 
@@ -343,7 +344,7 @@ Retrieves a directory listing. This method returns a Promise, which once realise
343
344
  The *glob*-style matching is very simple. In most cases, you are best off using a real regular expression which will allow you to do more powerful matching and anchor matches to the beginning/end of the string etc.
344
345
 
345
346
 
346
- <a id="orgaae7860"></a>
347
+ <a id="org14dee5e"></a>
347
348
 
348
349
  ### exists(path) ==> boolean
349
350
 
@@ -379,7 +380,7 @@ Tests to see if remote file or directory exists. Returns type of remote object i
379
380
  ```
380
381
 
381
382
 
382
- <a id="org1e4f14a"></a>
383
+ <a id="orga0033c0"></a>
383
384
 
384
385
  ### stat(path) ==> object
385
386
 
@@ -430,7 +431,7 @@ Returns the attributes associated with the object pointed to by `path`.
430
431
  ```
431
432
 
432
433
 
433
- <a id="org447f36c"></a>
434
+ <a id="org02a3dc5"></a>
434
435
 
435
436
  ### get(path, dst, options) ==> String|Stream|Buffer
436
437
 
@@ -486,7 +487,7 @@ In general, if you're going to pass in a string as the destination, you are bett
486
487
  - **Tip:** See examples file in the Git repository for more examples. You can pass any writeable stream in as the destination. For example, if you pass in `zlib.createGunzip()` writeable stream, you can both download and decompress a gzip file 'on the fly'.
487
488
 
488
489
 
489
- <a id="org54de461"></a>
490
+ <a id="orge9f875d"></a>
490
491
 
491
492
  ### fastGet(remotePath, localPath, options) ===> string
492
493
 
@@ -529,7 +530,7 @@ Downloads a file at remotePath to localPath using parallel reads for faster thro
529
530
  ```
530
531
 
531
532
 
532
- <a id="orgee0d1ef"></a>
533
+ <a id="orgc7941ea"></a>
533
534
 
534
535
  ### put(src, remotePath, options) ==> string
535
536
 
@@ -579,7 +580,7 @@ Upload data from local system to remote server. If the `src` argument is a strin
579
580
  - **Tip:** If the src argument is a path string, consider just using `fastPut()`.
580
581
 
581
582
 
582
- <a id="orgb9d8ee2"></a>
583
+ <a id="org8f8794d"></a>
583
584
 
584
585
  ### fastPut(localPath, remotePath, options) ==> string
585
586
 
@@ -623,7 +624,7 @@ Uploads the data in file at `localPath` to a new file on remote server at `remot
623
624
  ```
624
625
 
625
626
 
626
- <a id="org1eaae65"></a>
627
+ <a id="org82c75b5"></a>
627
628
 
628
629
  ### append(input, remotePath, options) ==> string
629
630
 
@@ -667,7 +668,7 @@ Append the `input` data to an existing remote file. There is no integrity checki
667
668
  ```
668
669
 
669
670
 
670
- <a id="org1c3ab90"></a>
671
+ <a id="org42c5eeb"></a>
671
672
 
672
673
  ### mkdir(path, recursive) ==> string
673
674
 
@@ -695,7 +696,7 @@ Create a new directory. If the recursive flag is set to true, the method will cr
695
696
  ```
696
697
 
697
698
 
698
- <a id="org003ef11"></a>
699
+ <a id="orgd0aa59d"></a>
699
700
 
700
701
  ### rmdir(path, recursive) ==> string
701
702
 
@@ -725,7 +726,7 @@ Remove a directory. If removing a directory and recursive flag is set to `true`,
725
726
  ```
726
727
 
727
728
 
728
- <a id="orgd3e3a35"></a>
729
+ <a id="orgb496048"></a>
729
730
 
730
731
  ### delete(path, noErrorOK) ==> string
731
732
 
@@ -754,7 +755,7 @@ Delete a file on the remote server.
754
755
  ```
755
756
 
756
757
 
757
- <a id="org3343888"></a>
758
+ <a id="org1a2be8f"></a>
758
759
 
759
760
  ### rename(fromPath, toPath) ==> string
760
761
 
@@ -783,7 +784,7 @@ Rename a file or directory from `fromPath` to `toPath`. You must have the necess
783
784
  ```
784
785
 
785
786
 
786
- <a id="orgb8f840c"></a>
787
+ <a id="org571c0b9"></a>
787
788
 
788
789
  ### posixRename(fromPath, toPath) ==> string
789
790
 
@@ -810,7 +811,7 @@ client.connect(config)
810
811
  ```
811
812
 
812
813
 
813
- <a id="org15551c9"></a>
814
+ <a id="org02d64a4"></a>
814
815
 
815
816
  ### chmod(path, mode) ==> string
816
817
 
@@ -839,7 +840,7 @@ Change the mode (read, write or execute permissions) of a remote file or directo
839
840
  ```
840
841
 
841
842
 
842
- <a id="org4ec95c3"></a>
843
+ <a id="org008d567"></a>
843
844
 
844
845
  ### realPath(path) ===> string
845
846
 
@@ -850,14 +851,14 @@ Converts a relative path to an absolute path on the remote server. This method i
850
851
  - **path:** A file path, either relative or absolute. Can handle '.' and '..', but does not expand '~'.
851
852
 
852
853
 
853
- <a id="orgc1265f0"></a>
854
+ <a id="org7033d28"></a>
854
855
 
855
856
  ### cwd() ==> string
856
857
 
857
858
  Returns what the server believes is the current remote working directory.
858
859
 
859
860
 
860
- <a id="org5c10c06"></a>
861
+ <a id="orgfa0102a"></a>
861
862
 
862
863
  ### uploadDir(srcDir, dstDir, options) ==> string
863
864
 
@@ -926,7 +927,7 @@ The `useFastput` option is a boolean option. If `true`, the method will use the
926
927
  ```
927
928
 
928
929
 
929
- <a id="org614dc71"></a>
930
+ <a id="orgefe6fc6"></a>
930
931
 
931
932
  ### downloadDir(srcDir, dstDir, options) ==> string
932
933
 
@@ -991,7 +992,7 @@ If the `useFastget` property is set to `true`, the method will use `fastGet()` t
991
992
  ```
992
993
 
993
994
 
994
- <a id="org906505f"></a>
995
+ <a id="org783e363"></a>
995
996
 
996
997
  ### createReadStream(remotePath, options)) ==> stream object
997
998
 
@@ -1008,7 +1009,7 @@ Returns a read stream object which is attached to the remote file specified by t
1008
1009
  - **end:** Postion to stop reading bytes (inclusive).
1009
1010
 
1010
1011
 
1011
- <a id="orgf5b3858"></a>
1012
+ <a id="orgf45313d"></a>
1012
1013
 
1013
1014
  ### createWriteStream(remotePath, options) ==> stream object
1014
1015
 
@@ -1023,7 +1024,7 @@ Returns a write stream object which is attached to the remote file specified in
1023
1024
  - **start:** Byte position to start writing from (inclusive). May require changing flag to 'r+'.
1024
1025
 
1025
1026
 
1026
- <a id="org3716ce1"></a>
1027
+ <a id="orga31c8c1"></a>
1027
1028
 
1028
1029
  ### rcopy(srcPath, dstPath) ==> string
1029
1030
 
@@ -1033,7 +1034,7 @@ Perfrom a remote file copy. The file identified by the `srcPath` argument will b
1033
1034
  - **dstPath:** Path to where the copy will be creaeted specified as a string
1034
1035
 
1035
1036
 
1036
- <a id="org93bfcf3"></a>
1037
+ <a id="org4d02fde"></a>
1037
1038
 
1038
1039
  ### end() ==> boolean
1039
1040
 
@@ -1057,7 +1058,7 @@ Ends the current client session, releasing the client socket and associated reso
1057
1058
  ```
1058
1059
 
1059
1060
 
1060
- <a id="org8fe6c29"></a>
1061
+ <a id="orge5769d3"></a>
1061
1062
 
1062
1063
  ### Add and Remove Listeners
1063
1064
 
@@ -1078,12 +1079,12 @@ Although normally not required, you can add and remove custom listeners on the s
1078
1079
  Removes the specified listener from the event specified in eventType. Note that the `end()` method automatically removes all listeners from the client object.
1079
1080
 
1080
1081
 
1081
- <a id="org763e7bf"></a>
1082
+ <a id="org3e6ddf9"></a>
1082
1083
 
1083
1084
  # Platform Quirks & Warnings
1084
1085
 
1085
1086
 
1086
- <a id="org3c7ec29"></a>
1087
+ <a id="org61f0fe5"></a>
1087
1088
 
1088
1089
  ## Server Capabilities
1089
1090
 
@@ -1092,7 +1093,7 @@ All SFTP servers and platforms are not equal. Some facilities provided by `ssh2-
1092
1093
  One way to determine whether an issue you are encountering is due to `ssh2-sftp-client` or due to the remote server or server platform is to use a simple CLI sftp program, such as openSSH's sftp command. If you observe the same behaviour using plain `sftp` on the command line, the issue is likely due to server or remote platform limitations. Note that you should not use a GUI sftp client, like `Filezilla` or `winSCP` as such GUI programs often attempt to hide these server and platform incompatibilities and will take additional steps to simulate missing functionality etc. You want to use a CLI program which does as little as possible.
1093
1094
 
1094
1095
 
1095
- <a id="org13e7f16"></a>
1096
+ <a id="orga7d6067"></a>
1096
1097
 
1097
1098
  ## Promises, Events & Managing Exceptions
1098
1099
 
@@ -1111,14 +1112,14 @@ The other area where additional events are fired is during the end() call. To de
1111
1112
  In addition to the promise based event handlers, `ssh2-sftp-client` also implements global event handlers which will catch any `error`, `end` or `close` events. Essentially, these global handlers only reset the `sftp` property of the client object, effectively ensuring any subsequent calls are rejected and in the case of an error, send the error to the console.
1112
1113
 
1113
1114
 
1114
- <a id="orgbea2ca0"></a>
1115
+ <a id="orgc08d427"></a>
1115
1116
 
1116
1117
  ### Adding Custom Handlers
1117
1118
 
1118
1119
  While the above strategies appear to work for the majority of use cases, there are always going to be edge cases which require more flexible or powerful event handling. To support this, the `on()` and `removeListener()` methods are provided. Any event listener added using the `on()` method will be added at the beginning of the list of handlers for that event, ensuring it will be called before any global or promise local events. See the documentation for the `on()` method for details.
1119
1120
 
1120
1121
 
1121
- <a id="org13d5c2b"></a>
1122
+ <a id="org5439468"></a>
1122
1123
 
1123
1124
  ## Windows Based Servers
1124
1125
 
@@ -1127,7 +1128,7 @@ It appears that when the sftp server is running on Windows, a *ECONNRESET* error
1127
1128
  The best way to avoid this issue is to not re-use client objects. Always generate a new sftp client object for each new connection.
1128
1129
 
1129
1130
 
1130
- <a id="org56317e1"></a>
1131
+ <a id="orgae9129c"></a>
1131
1132
 
1132
1133
  ## Don't Re-use SftpClient Objects
1133
1134
 
@@ -1136,12 +1137,12 @@ Due to an issue with *ECONNRESET* error signals when connecting to Windows based
1136
1137
  To avoid this problem, don't re-use SftpClient objects. Generate a new SftpClient object for each connection. You can perform multiple actions with a single connection e.g. upload multiple files, download multiple files etc, but after you have called end(), you should not try to re-use the object with a further connect() call. Create a new object instead.
1137
1138
 
1138
1139
 
1139
- <a id="orgb28c841"></a>
1140
+ <a id="org3761660"></a>
1140
1141
 
1141
1142
  # FAQ
1142
1143
 
1143
1144
 
1144
- <a id="orgb4c1c9d"></a>
1145
+ <a id="org1e669d1"></a>
1145
1146
 
1146
1147
  ## Remote server drops connections with only an end event
1147
1148
 
@@ -1152,7 +1153,7 @@ Clients first make an unauthenticated connection to the SFTP server to begin neg
1152
1153
  One way to avoid this type of issue is to add a delay between connection attempts. It does not need to be a very long delay - just sufficient to permit the previous connection to be authenticated. In fact, the default setting for openSSH is `10:30:60`, so you really just need to have enough delay to ensure that the 1st connection has completed authentication before the 11th connection is attempted.
1153
1154
 
1154
1155
 
1155
- <a id="orgf09bf16"></a>
1156
+ <a id="org71d5bab"></a>
1156
1157
 
1157
1158
  ## How can I pass writable stream as dst for get method?
1158
1159
 
@@ -1211,7 +1212,7 @@ sftp
1211
1212
  ```
1212
1213
 
1213
1214
 
1214
- <a id="org10382e7"></a>
1215
+ <a id="orgaafc964"></a>
1215
1216
 
1216
1217
  ## How can I upload files without having to specify a password?
1217
1218
 
@@ -1246,7 +1247,7 @@ sftp.connect({
1246
1247
  ```
1247
1248
 
1248
1249
 
1249
- <a id="org34d3eb7"></a>
1250
+ <a id="orgebf85e2"></a>
1250
1251
 
1251
1252
  ## How can I connect through a Socks Proxy
1252
1253
 
@@ -1282,7 +1283,7 @@ client.connect({
1282
1283
  ```
1283
1284
 
1284
1285
 
1285
- <a id="orgbe4be79"></a>
1286
+ <a id="org528d9ea"></a>
1286
1287
 
1287
1288
  ## Timeout while waiting for handshake or handshake errors
1288
1289
 
@@ -1291,7 +1292,7 @@ Some users have encountered the error 'Timeout while waiting for handshake' or '
1291
1292
  When encountering this type of problem, one worthwhile approach is to use openSSH's CLI sftp program with the `-v` switch to raise loggin levels. This will show you what algorithms the CLI is using. You can then use this information to match the names with the accepted algorithm names documented in the `ssh2` README to set the properties in the `algorithms` object.
1292
1293
 
1293
1294
 
1294
- <a id="org36a1f06"></a>
1295
+ <a id="org3b6ff20"></a>
1295
1296
 
1296
1297
  ## How can I limit upload/download speed
1297
1298
 
@@ -1331,7 +1332,7 @@ try {
1331
1332
  ```
1332
1333
 
1333
1334
 
1334
- <a id="org293ce0b"></a>
1335
+ <a id="orgb5e285f"></a>
1335
1336
 
1336
1337
  ## Connection hangs or fails for larger files
1337
1338
 
@@ -1342,14 +1343,14 @@ A symptom of this issue is that you are able to upload small files, but uploadin
1342
1343
  For more explanation, see [issue #342](https://github.com/theophilusx/ssh2-sftp-client/issues/342).
1343
1344
 
1344
1345
 
1345
- <a id="org897888b"></a>
1346
+ <a id="org18ce0c2"></a>
1346
1347
 
1347
1348
  # Examples
1348
1349
 
1349
1350
  I have started collecting example scripts in the example directory of the repository. These are mainly scripts I have put together in order to investigate issues or provide samples for users. They are not robust, lack adequate error handling and may contain errors. However, I think they are still useful for helping developers see how the module and API can be used.
1350
1351
 
1351
1352
 
1352
- <a id="orgd93090a"></a>
1353
+ <a id="orgf4b6c80"></a>
1353
1354
 
1354
1355
  # Troubleshooting
1355
1356
 
@@ -1364,14 +1365,14 @@ Note also that in the repository there are two useful directories. The first is
1364
1365
  The second directory is the validation directory. I have some very simple scripts in this directory which perform basic tasks using only the `ssh2` modules (no `ssh2-sftp-client` module). These can be useful when trying to determine if the issue is with the underlying `ssh2` module or the `ssh2-sftp-client` wrapper module.
1365
1366
 
1366
1367
 
1367
- <a id="org44294d4"></a>
1368
+ <a id="orga419582"></a>
1368
1369
 
1369
1370
  ## Common Errors
1370
1371
 
1371
1372
  There are some common errors people tend to make when using Promises or Asyc/Await. These are by far the most common problem found in issues logged against this module. Please check for some of these before logging your issue.
1372
1373
 
1373
1374
 
1374
- <a id="org44783ba"></a>
1375
+ <a id="orgd5f3557"></a>
1375
1376
 
1376
1377
  ### Not returning the promise in a `then()` block
1377
1378
 
@@ -1408,7 +1409,7 @@ Note the `return` statements. These ensure that the Promise returned by the clie
1408
1409
  A common symptom of this type of error is for file uploads or download to fail to complete or for data in those files to be truncated. What is happening is that the connection is being ended before the transfer has completed.
1409
1410
 
1410
1411
 
1411
- <a id="org1bee008"></a>
1412
+ <a id="org557d1c5"></a>
1412
1413
 
1413
1414
  ### Mixing Promise Chains and Async/Await
1414
1415
 
@@ -1468,7 +1469,7 @@ async function doSftp() {
1468
1469
  ```
1469
1470
 
1470
1471
 
1471
- <a id="org004696d"></a>
1472
+ <a id="org2bf9a3a"></a>
1472
1473
 
1473
1474
  ### Try/catch and Error Handlers
1474
1475
 
@@ -1479,14 +1480,14 @@ The basic problem is that the try/catch block will have completed execution befo
1479
1480
  Error events are essentially asynchronous code. You don't know when such events will fire. Therefore, you cannot use a try/catch block to catch such event errors. Even creating an error handler which then throws an exception won't help as the key problem is that your try/catch block has already executed. There are a number of alternative ways to deal with this situation. However, the key symptom is that you see occasional uncaught error exceptions that cause your script to exit abnormally despite having try/catch blocks in your script. What you need to do is look at your code and find where errors are raised asynchronously and use an event handler or some other mechanism to manage any errors raised.
1480
1481
 
1481
1482
 
1482
- <a id="org9131050"></a>
1483
+ <a id="org89795d7"></a>
1483
1484
 
1484
1485
  ### Server Differences
1485
1486
 
1486
1487
  Not all SFTP servers are the same. Like most standards, the SFTP protocol has some level of interpretation and allows different levels of compliance. This means there can be differences in behaviour between different servers and code which works with one server will not work the same with another. For example, the value returned by *realpath* for non-existent objects can differ significantly. Some servers will throw an error for a particular operation while others will just return null, some servers support concurrent operations (such as used by fastGet/fastPut) while others will not and of course, the text of error messages can vary significantly. In particular, we have noticed significant differences across different platforms. It is therefore advisable to do comprehensive testing when the SFTP server is moved to a new platform. This includes moving from to a cloud based service even if the underlying platform remains the same. I have noticed that some cloud platforms can generate unexpected events, possibly related to additional functionality or features associated with the cloud implementation. For example, it appears SFTP servers running under Azure will generate an error event when the connection is closed even when the client has requested the connection be terminated. The same SFTP server running natively on Windows does not appear to exhibit such behaviour.
1487
1488
 
1488
1489
 
1489
- <a id="org6c9fbb1"></a>
1490
+ <a id="orgbec08b0"></a>
1490
1491
 
1491
1492
  ### Avoid Concurrent Operations
1492
1493
 
@@ -1495,7 +1496,7 @@ Technically, SFTP should be able to perform multiple operations concurrently. As
1495
1496
  If you are going to try and perform concurrent operations, you need to test extensively and ensure you are using data which is large enough that context switching does occur (i.e. the request is not completed in a single run). Some SFTP servers will handle concurrent operations better than others.
1496
1497
 
1497
1498
 
1498
- <a id="org52099c1"></a>
1499
+ <a id="org124cfc9"></a>
1499
1500
 
1500
1501
  ## Debugging Support
1501
1502
 
@@ -1528,7 +1529,7 @@ If you just want to see debug messages from `ssh2-sftp-client` and exclude debug
1528
1529
  ```
1529
1530
 
1530
1531
 
1531
- <a id="orga96ad01"></a>
1532
+ <a id="org5f3c941"></a>
1532
1533
 
1533
1534
  # Logging Issues
1534
1535
 
@@ -1545,7 +1546,7 @@ I am happy to try and help diagnose and fix any issues you encounter while using
1545
1546
  Perhaps the best assistance is a minimal reproducible example of the issue. Once the issue can be readily reproduced, it can usually be fixed very quickly.
1546
1547
 
1547
1548
 
1548
- <a id="org0fa18ba"></a>
1549
+ <a id="org6e82efc"></a>
1549
1550
 
1550
1551
  # Pull Requests
1551
1552
 
@@ -1560,7 +1561,7 @@ This module will adopt a standard semantic versioning policy. Please indicate in
1560
1561
  - **Bug Fix:** No change to functionality or features. Simple fix of an existing bug.
1561
1562
 
1562
1563
 
1563
- <a id="org05880d2"></a>
1564
+ <a id="org680b5c2"></a>
1564
1565
 
1565
1566
  # Contributors
1566
1567
 
package/README.org CHANGED
@@ -9,16 +9,15 @@ convenience abstraction as well as a Promise based API.
9
9
  Documentation on the methods and available options in the underlying modules can
10
10
  be found on the [[https://github.com/mscdex/ssh2][SSH2]] project pages.
11
11
 
12
- Current stable release is *v9.0.0*.
12
+ Current stable release is *v9.0.1*.
13
13
 
14
14
  Code has been tested against Node versions 14.19.1, 16.15.0 and 18.1.0
15
15
 
16
- Node versions < 12.x are not supported. However, node v10.x should still work,
17
- although some tests will fail due to changes in file system functions used in
18
- test setup and tear down.
16
+ Node versions < 14.x are not supported.
19
17
 
20
18
  ** Version 9.x Changes
21
-
19
+ - *Breaking Change*: This version uses syntax not supported in node versions
20
+ prior to v14. Therefore, node versions less than v14 will not work.
22
21
  - *Breaking Change*: This ~list()~ method no longer accepts a regular expression
23
22
  for filtering the entries to be returned. You can now specify a filter
24
23
  function instead. The function is called for each item in the list of items
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssh2-sftp-client",
3
- "version": "9.0.0",
3
+ "version": "9.0.1",
4
4
  "description": "ssh2 sftp client for node",
5
5
  "main": "src/index.js",
6
6
  "repository": {
package/src/index.js CHANGED
@@ -540,7 +540,7 @@ class SftpClient {
540
540
  });
541
541
  if (dst === undefined) {
542
542
  // no dst specified, return buffer of data
543
- this.debugMsg('get returning buffer of data');
543
+ this.debugMsg('get resolving buffer of data');
544
544
  wtr = concat((buff) => {
545
545
  resolve(buff);
546
546
  });
@@ -575,8 +575,10 @@ class SftpClient {
575
575
  });
576
576
  rdr.once('end', () => {
577
577
  if (typeof dst === 'string') {
578
+ this.debugMsg('get: resolving with dst filename');
578
579
  resolve(dst);
579
- } else {
580
+ } else if (dst !== undefined) {
581
+ this.debugMsg('get: resolving with writer stream object');
580
582
  resolve(wtr);
581
583
  }
582
584
  });
package/.dir-local.el DELETED
@@ -1 +0,0 @@
1
- ((js2-mode .((flycheck-javascript-eslint-executable . "~/git/ssh2-sftp-client/node-modules/.bin/eslint"))))