bdy 1.9.5-dev → 1.9.6-dev

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.9.5-dev",
4
+ "version": "1.9.6-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -7,6 +7,7 @@ const logger_1 = __importDefault(require("../logger"));
7
7
  const ssh2_1 = __importDefault(require("ssh2"));
8
8
  const promises_1 = __importDefault(require("fs/promises"));
9
9
  const path_1 = __importDefault(require("path"));
10
+ const node_os_1 = require("node:os");
10
11
  const { flagsToString, STATUS_CODE } = ssh2_1.default.utils.sftp;
11
12
  class ServerSftp {
12
13
  constructor(sftp) {
@@ -33,12 +34,24 @@ class ServerSftp {
33
34
  this.sftp.on('RENAME', (reqId, oldPath, newPath) => this.rename(reqId, oldPath, newPath));
34
35
  this.sftp.on('SYMLINK', (reqId, linkPath, targetPath) => this.symlink(reqId, linkPath, targetPath));
35
36
  }
37
+ debugStart(txt) {
38
+ logger_1.default.debug(txt);
39
+ return process.hrtime();
40
+ }
41
+ debugEnd(txt, s, err) {
42
+ const [seconds, nano] = process.hrtime(s);
43
+ const ms = seconds * 1000 + nano / 1000 / 1000;
44
+ logger_1.default.debug(`${txt} in ${ms}ms`);
45
+ if (err)
46
+ logger_1.default.debug(err);
47
+ }
36
48
  async open(reqId, fileName, flags, attrs) {
37
- logger_1.default.debug(`SFTP want to open file ${fileName}`);
49
+ const s = this.debugStart(`SFTP want to open file ${fileName}`);
38
50
  try {
39
51
  const flag = flagsToString(flags);
40
52
  if (!flag) {
41
53
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
54
+ this.debugEnd('SFTP open file failed', s);
42
55
  return;
43
56
  }
44
57
  const id = ++this.count;
@@ -47,21 +60,21 @@ class ServerSftp {
47
60
  const fd = await promises_1.default.open(fileName, flag);
48
61
  this.openHandlers.set(id, fd);
49
62
  await this._fsetstat(fd, attrs);
50
- logger_1.default.debug('SFTP open file succeed');
51
63
  this.sftp.handle(reqId, handle);
64
+ this.debugEnd('SFTP open file succeed', s);
52
65
  }
53
66
  catch (err) {
54
- logger_1.default.debug('SFTP open file failed');
55
- logger_1.default.debug(err);
56
67
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
68
+ this.debugEnd('SFTP open file failed', s, err);
57
69
  }
58
70
  }
59
71
  async read(reqId, handle, offset, length) {
60
- logger_1.default.debug('SFTP want to read file');
72
+ const s = this.debugStart('SFTP want to read file');
61
73
  try {
62
74
  const id = handle.readUInt32BE(0);
63
75
  if (!this.openHandlers.has(id)) {
64
76
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
77
+ this.debugEnd('SFTP read file failed', s);
65
78
  return;
66
79
  }
67
80
  const fd = this.openHandlers.get(id);
@@ -71,7 +84,6 @@ class ServerSftp {
71
84
  length,
72
85
  position: offset,
73
86
  });
74
- logger_1.default.debug('SFTP read file succeed');
75
87
  if (r.bytesRead <= 0) {
76
88
  this.sftp.status(reqId, STATUS_CODE.EOF);
77
89
  }
@@ -84,140 +96,136 @@ class ServerSftp {
84
96
  else {
85
97
  this.sftp.data(reqId, buffer);
86
98
  }
99
+ this.debugEnd('SFTP read file succeed', s);
87
100
  }
88
101
  catch (err) {
89
- logger_1.default.debug('SFTP read file failed');
90
- logger_1.default.debug(err);
91
102
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
103
+ this.debugEnd('SFTP read file failed', s, err);
92
104
  }
93
105
  }
94
106
  async write(reqId, handle, offset, data) {
95
- logger_1.default.debug('SFTP want to write file');
107
+ const s = this.debugStart('SFTP want to write file');
96
108
  try {
97
109
  const id = handle.readUInt32BE(0);
98
110
  if (!this.openHandlers.has(id)) {
99
111
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
112
+ this.debugEnd('SFTP write file failed', s);
100
113
  return;
101
114
  }
102
115
  const fd = this.openHandlers.get(id);
103
116
  await fd.write(data, 0, data.length, offset);
104
- logger_1.default.debug('SFTP write file succeed');
105
117
  this.sftp.status(reqId, STATUS_CODE.OK);
118
+ this.debugEnd('SFTP write file succeed', s);
106
119
  }
107
120
  catch (err) {
108
- logger_1.default.debug('SFTP write file failed');
109
- logger_1.default.debug(err);
110
121
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
122
+ this.debugEnd('SFTP write file failed', s, err);
111
123
  }
112
124
  }
113
125
  async close(reqId, handle) {
114
- logger_1.default.debug('SFTP want to close handler');
126
+ const s = this.debugStart('SFTP want to close handler');
115
127
  try {
116
128
  const id = handle.readUInt32BE(0);
117
129
  if (!this.openHandlers.has(id)) {
118
130
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
131
+ this.debugEnd('SFTP close handler failed', s);
119
132
  return;
120
133
  }
121
134
  const fd = this.openHandlers.get(id);
122
135
  await fd.close();
123
136
  this.openHandlers.delete(id);
124
- logger_1.default.debug('SFTP closed handler succeed');
125
137
  this.sftp.status(reqId, STATUS_CODE.OK);
138
+ this.debugEnd('SFTP closed handler succeed', s);
126
139
  }
127
140
  catch (err) {
128
- logger_1.default.debug('SFTP close handler failed');
129
- logger_1.default.debug(err);
130
141
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
142
+ this.debugEnd('SFTP close handler failed', s, err);
131
143
  }
132
144
  }
133
145
  async fstat(reqId, handle) {
134
- logger_1.default.debug('SFTP want to stat file');
146
+ const s = this.debugStart('SFTP want to stat file');
135
147
  try {
136
148
  const id = handle.readUInt32BE(0);
137
149
  if (!this.openHandlers.has(id)) {
138
150
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
151
+ this.debugEnd('SFTP stat file failed', s);
139
152
  return;
140
153
  }
141
154
  const fd = this.openHandlers.get(id);
142
155
  const attrs = await fd.stat();
143
- logger_1.default.debug('SFTP stat file succeed');
144
156
  this.sftp.attrs(reqId, attrs);
157
+ this.debugEnd('SFTP stat file succeed', s);
145
158
  }
146
159
  catch (err) {
147
- logger_1.default.debug('SFTP stat file failed');
148
- logger_1.default.debug(err);
149
160
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
161
+ this.debugEnd('SFTP stat file failed', s, err);
150
162
  }
151
163
  }
152
164
  async _fsetstat(fd, attrs) {
153
165
  if (Number.isInteger(attrs.uid) && Number.isInteger(attrs.gid)) {
166
+ const s = this.debugStart(`SFTP want to chown with uid: ${attrs.uid}, gid: ${attrs.gid}`);
154
167
  try {
155
- logger_1.default.debug(`SFTP want to chown with uid: ${attrs.uid}, gid: ${attrs.gid}`);
156
168
  await fd.chown(attrs.uid, attrs.gid);
157
- logger_1.default.debug('SFTP chown succeed');
169
+ this.debugEnd('SFTP chown succeed', s);
158
170
  }
159
171
  catch (err) {
160
- logger_1.default.debug('SFTP chown failed');
161
- logger_1.default.debug(err);
172
+ this.debugEnd('SFTP chown failed', s, err);
162
173
  }
163
174
  }
164
175
  if (attrs.mode) {
176
+ const s = this.debugStart(`SFTP want to chmod with mode: ${attrs.mode}`);
165
177
  try {
166
- logger_1.default.debug(`SFTP want to chmod with mode: ${attrs.mode}`);
167
178
  await fd.chmod(attrs.mode);
168
- logger_1.default.debug('SFTP chmod succeed');
179
+ this.debugEnd('SFTP chmod succeed', s);
169
180
  }
170
181
  catch (err) {
171
- logger_1.default.debug('SFTP chmod failed');
172
- logger_1.default.debug(err);
182
+ this.debugEnd('SFTP chmod failed', s, err);
173
183
  }
174
184
  }
175
185
  if (attrs.atime && attrs.mtime) {
186
+ const s = this.debugStart(`SFTP want to utimes with atime: ${attrs.atime}, mtime: ${attrs.mtime}`);
176
187
  try {
177
- logger_1.default.debug(`SFTP want to utimes with atime: ${attrs.atime}, mtime: ${attrs.mtime}`);
178
188
  await fd.utimes(attrs.atime, attrs.mtime);
179
- logger_1.default.debug('SFTP utimes succeed');
189
+ this.debugEnd('SFTP utimes succeed', s);
180
190
  }
181
191
  catch (err) {
182
- logger_1.default.debug('SFTP utimes failed');
183
- logger_1.default.debug(err);
192
+ this.debugEnd('SFTP utimes failed', s, err);
184
193
  }
185
194
  }
186
195
  }
187
196
  async fsetstat(reqId, handle, attrs) {
188
- logger_1.default.debug('SFTP want to set attrs of file');
197
+ const s = this.debugStart('SFTP want to set attrs of file');
189
198
  try {
190
199
  const id = handle.readUInt32BE(0);
191
200
  if (!this.openHandlers.has(id)) {
192
201
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
202
+ this.debugEnd('SFTP set attrs of file failed', s);
193
203
  return;
194
204
  }
195
205
  const fd = this.openHandlers.get(id);
196
206
  await this._fsetstat(fd, attrs);
197
- logger_1.default.debug('SFTP set attrs of file succeed');
198
207
  this.sftp.status(reqId, STATUS_CODE.OK);
208
+ this.debugEnd('SFTP set attrs of file succeed', s);
199
209
  }
200
210
  catch (err) {
201
- logger_1.default.debug('SFTP set attrs of file failed');
202
- logger_1.default.debug(err);
203
211
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
212
+ this.debugEnd('SFTP set attrs of file failed', s, err);
204
213
  }
205
214
  }
206
215
  async opendir(reqId, path) {
207
- logger_1.default.debug(`SFTP want to open directory ${path}`);
216
+ const s = this.debugStart(`SFTP want to open directory ${path}`);
208
217
  try {
209
218
  const id = ++this.count;
210
219
  const handle = Buffer.alloc(4);
211
220
  handle.writeUint32BE(id, 0);
212
221
  const fd = await promises_1.default.opendir(path);
213
222
  this.openHandlers.set(id, fd);
214
- logger_1.default.debug('SFTP open directory succeed');
215
223
  this.sftp.handle(reqId, handle);
224
+ this.debugEnd('SFTP open directory succeed', s);
216
225
  }
217
226
  catch (err) {
218
- logger_1.default.debug('SFTP open directory failed');
219
- logger_1.default.debug(err);
220
227
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
228
+ this.debugEnd('SFTP open directory failed', s, err);
221
229
  }
222
230
  }
223
231
  formatMode(mode) {
@@ -255,212 +263,214 @@ class ServerSftp {
255
263
  ].join('');
256
264
  }
257
265
  async readdir(reqId, handle) {
258
- logger_1.default.debug('SFTP want to read directory');
266
+ const s = this.debugStart('SFTP want to read directory');
259
267
  try {
260
268
  const id = handle.readUInt32BE(0);
261
269
  if (!this.openHandlers.has(id)) {
262
270
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
271
+ this.debugEnd('SFTP read directory failed', s);
263
272
  return;
264
273
  }
265
274
  const fd = this.openHandlers.get(id);
266
- const dir = await fd.read();
267
- if (!dir) {
268
- logger_1.default.debug('SFTP read directory ended');
269
- this.sftp.status(reqId, STATUS_CODE.EOF);
270
- }
271
- else {
272
- const name = dir.name;
273
- const fullPath = path_1.default.join(fd.path, name);
274
- const stat = await promises_1.default.lstat(fullPath);
275
- const longname = await this.longname(fullPath, name, stat);
276
- logger_1.default.debug('SFTP read directory succeed');
277
- this.sftp.name(reqId, {
278
- filename: name,
279
- longname,
280
- attrs: stat,
281
- });
275
+ const names = [];
276
+ let r = 0;
277
+ const m = 1000;
278
+ while (r < m) {
279
+ const dir = await fd.read();
280
+ if (!dir && !r) {
281
+ this.sftp.status(reqId, STATUS_CODE.EOF);
282
+ this.debugEnd('SFTP read directory ended', s);
283
+ return;
284
+ }
285
+ else if (!dir) {
286
+ break;
287
+ }
288
+ else {
289
+ const name = dir.name;
290
+ const fullPath = path_1.default.join(fd.path, name);
291
+ const stat = await promises_1.default.lstat(fullPath);
292
+ const longname = await this.longname(fullPath, name, stat);
293
+ names.push({
294
+ filename: name,
295
+ longname,
296
+ attrs: stat,
297
+ });
298
+ r += 1;
299
+ }
282
300
  }
301
+ this.sftp.name(reqId, names);
302
+ this.debugEnd(`SFTP read directory ${fd.path} succeed`, s);
283
303
  }
284
304
  catch (err) {
285
- logger_1.default.debug('SFTP read directory failed');
286
- logger_1.default.debug(err);
287
305
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
306
+ this.debugEnd('SFTP read directory failed', s, err);
288
307
  }
289
308
  }
290
309
  async stat(reqId, path) {
291
- logger_1.default.debug(`SFTP want to stat ${path}`);
310
+ const s = this.debugStart(`SFTP want to stat ${path}`);
292
311
  try {
293
312
  const attrs = await promises_1.default.stat(path);
294
- logger_1.default.debug('SFTP stat path succeed');
295
313
  this.sftp.attrs(reqId, attrs);
314
+ this.debugEnd('SFTP stat path succeed', s);
296
315
  }
297
316
  catch (err) {
298
- logger_1.default.debug('SFTP stat path failed');
299
- logger_1.default.debug(err);
300
317
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
318
+ this.debugEnd('SFTP stat path failed', s, err);
301
319
  }
302
320
  }
303
321
  async remove(reqId, path) {
304
- logger_1.default.debug(`SFTP want to remove file ${path}`);
322
+ const s = this.debugStart(`SFTP want to remove file ${path}`);
305
323
  try {
306
324
  await promises_1.default.rm(path);
307
- logger_1.default.debug('SFTP removed file succeed');
308
325
  this.sftp.status(reqId, STATUS_CODE.OK);
326
+ this.debugEnd('SFTP removed file succeed', s);
309
327
  }
310
328
  catch (err) {
311
- logger_1.default.debug('SFTP remove file failed');
312
- logger_1.default.debug(err);
313
329
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
330
+ this.debugEnd('SFTP remove file failed', s, err);
314
331
  }
315
332
  }
316
333
  async rmdir(reqId, path) {
317
- logger_1.default.debug(`SFTP want to remove directory ${path}`);
334
+ const s = this.debugStart(`SFTP want to remove directory ${path}`);
318
335
  try {
319
336
  await promises_1.default.rmdir(path, {
320
337
  recursive: true,
321
338
  });
322
- logger_1.default.debug('SFTP remove directory succeed');
323
339
  this.sftp.status(reqId, STATUS_CODE.OK);
340
+ this.debugEnd('SFTP remove directory succeed', s);
324
341
  }
325
342
  catch (err) {
326
- logger_1.default.debug('SFTP remove directory failed');
327
- logger_1.default.debug(err);
328
343
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
344
+ this.debugEnd('SFTP remove directory failed', s, err);
329
345
  }
330
346
  }
331
347
  async realpath(reqId, path) {
332
- logger_1.default.debug(`SFTP want realpath ${path}`);
348
+ const s = this.debugStart(`SFTP want realpath ${path}`);
333
349
  try {
334
- const realPath = await promises_1.default.realpath(path || '~/');
335
- logger_1.default.debug('SFTP realpath succeed');
350
+ let p = path || '~/';
351
+ if (p.includes('~')) {
352
+ p = p.replaceAll('~', (0, node_os_1.homedir)());
353
+ }
354
+ const realPath = await promises_1.default.realpath(p);
336
355
  this.sftp.name(reqId, [
337
356
  {
338
357
  filename: realPath,
339
358
  },
340
359
  ]);
360
+ this.debugEnd('SFTP realpath succeed', s);
341
361
  }
342
362
  catch (err) {
343
- logger_1.default.debug('SFTP realpath failed');
344
- logger_1.default.debug(err);
345
363
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
364
+ this.debugEnd('SFTP realpath failed', s, err);
346
365
  }
347
366
  }
348
367
  async readlink(reqId, path) {
349
- logger_1.default.debug(`SFTP want readlink ${path}`);
368
+ const s = this.debugStart(`SFTP want readlink ${path}`);
350
369
  try {
351
370
  const realPath = await promises_1.default.readlink(path);
352
- logger_1.default.debug('SFTP readlink succeed');
353
371
  this.sftp.name(reqId, [
354
372
  {
355
373
  filename: realPath,
356
374
  },
357
375
  ]);
376
+ this.debugEnd('SFTP readlink succeed', s);
358
377
  }
359
378
  catch (err) {
360
- logger_1.default.debug('SFTP readlink failed');
361
- logger_1.default.debug(err);
362
379
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
380
+ this.debugEnd('SFTP readlink failed', s, err);
363
381
  }
364
382
  }
365
383
  async _setstat(path, attrs) {
366
384
  if (Number.isInteger(attrs.uid) && Number.isInteger(attrs.gid)) {
385
+ const s = this.debugStart(`SFTP want chown with uid: ${attrs.uid}, gid: ${attrs.gid}`);
367
386
  try {
368
- logger_1.default.debug(`SFTP want chown with uid: ${attrs.uid}, gid: ${attrs.gid}`);
369
387
  await promises_1.default.chown(path, attrs.uid, attrs.gid);
370
- logger_1.default.debug('SFTP chown succeed');
388
+ this.debugEnd('SFTP chown succeed', s);
371
389
  }
372
390
  catch (err) {
373
- logger_1.default.debug('SFTP chown failed');
374
- logger_1.default.debug(err);
391
+ this.debugEnd('SFTP chown failed', s, err);
375
392
  }
376
393
  }
377
394
  if (attrs.mode) {
395
+ const s = this.debugStart(`SFTP want to chmod with mode: ${attrs.mode}`);
378
396
  try {
379
- logger_1.default.debug(`SFTP want to chmod with mode: ${attrs.mode}`);
380
397
  await promises_1.default.chmod(path, attrs.mode);
381
- logger_1.default.debug('SFTP chmod succeed');
398
+ this.debugEnd('SFTP chmod succeed', s);
382
399
  }
383
400
  catch (err) {
384
- logger_1.default.debug('SFTP chmod failed');
385
- logger_1.default.debug(err);
401
+ this.debugEnd('SFTP chmod failed', s, err);
386
402
  }
387
403
  }
388
404
  if (attrs.atime && attrs.mtime) {
405
+ const s = this.debugStart(`SFTP want to utimes with atime: ${attrs.atime}, mtime: ${attrs.mtime}`);
389
406
  try {
390
- logger_1.default.debug(`SFTP want to utimes with atime: ${attrs.atime}, mtime: ${attrs.mtime}`);
391
407
  await promises_1.default.utimes(path, attrs.atime, attrs.mtime);
392
- logger_1.default.debug('SFTP utimes succeed');
408
+ this.debugEnd('SFTP utimes succeed', s);
393
409
  }
394
410
  catch (err) {
395
- logger_1.default.debug('SFTP utimes failed');
396
- logger_1.default.debug(err);
411
+ this.debugEnd('SFTP utimes failed', s, err);
397
412
  }
398
413
  }
399
414
  }
400
415
  async setstat(reqId, path, attrs) {
401
- logger_1.default.debug(`SFTP want to set attrs ${path}`);
416
+ const s = this.debugStart(`SFTP want to set attrs ${path}`);
402
417
  try {
403
418
  await this._setstat(path, attrs);
404
- logger_1.default.debug('SFTP set attrs succeed');
405
419
  this.sftp.status(reqId, STATUS_CODE.OK);
420
+ this.debugEnd('SFTP set attrs succeed', s);
406
421
  }
407
422
  catch (err) {
408
- logger_1.default.debug('SFTP set attrs failed');
409
- logger_1.default.debug(err);
410
423
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
424
+ this.debugEnd('SFTP set attrs failed', s, err);
411
425
  }
412
426
  }
413
427
  async mkdir(reqId, path, attrs) {
414
- logger_1.default.debug(`SFTP want to create directory ${path}`);
428
+ const s = this.debugStart(`SFTP want to create directory ${path}`);
415
429
  try {
416
430
  await promises_1.default.mkdir(path);
417
431
  await this._setstat(path, attrs);
418
- logger_1.default.debug('SFTP create directory succeed');
419
432
  this.sftp.status(reqId, STATUS_CODE.OK);
433
+ this.debugEnd('SFTP create directory succeed', s);
420
434
  }
421
435
  catch (err) {
422
- logger_1.default.debug('SFTP create directory failed');
423
- logger_1.default.debug(err);
424
436
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
437
+ this.debugEnd('SFTP create directory failed', s, err);
425
438
  }
426
439
  }
427
440
  async rename(reqId, oldPath, newPath) {
428
- logger_1.default.debug(`SFTP want to rename path ${oldPath} to ${newPath}`);
441
+ const s = this.debugStart(`SFTP want to rename path ${oldPath} to ${newPath}`);
429
442
  try {
430
443
  await promises_1.default.rename(oldPath, newPath);
431
- logger_1.default.debug('SFTP rename path succeed');
432
444
  this.sftp.status(reqId, STATUS_CODE.OK);
445
+ this.debugEnd('SFTP rename path succeed', s);
433
446
  }
434
447
  catch (err) {
435
- logger_1.default.debug('SFTP rename path failed');
436
- logger_1.default.debug(err);
437
448
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
449
+ this.debugEnd('SFTP rename path failed', s, err);
438
450
  }
439
451
  }
440
452
  async symlink(reqId, linkPath, targetPath) {
441
- logger_1.default.debug(`SFTP want to symlink ${targetPath} at ${linkPath}`);
453
+ const s = this.debugStart(`SFTP want to symlink ${targetPath} at ${linkPath}`);
442
454
  try {
443
455
  await promises_1.default.symlink(targetPath, linkPath);
444
- logger_1.default.debug('SFTP symlink succeed');
445
456
  this.sftp.status(reqId, STATUS_CODE.OK);
457
+ this.debugEnd('SFTP symlink succeed', s);
446
458
  }
447
459
  catch (err) {
448
- logger_1.default.debug('SFTP symlink failed');
449
- logger_1.default.debug(err);
450
460
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
461
+ this.debugEnd('SFTP symlink failed', s, err);
451
462
  }
452
463
  }
453
464
  async lstat(reqId, path) {
454
- logger_1.default.debug(`SFTP want to lstat ${path}`);
465
+ const s = this.debugStart(`SFTP want to lstat ${path}`);
455
466
  try {
456
467
  const attrs = await promises_1.default.lstat(path);
457
- logger_1.default.debug('SFTP lstat path succeed');
458
468
  this.sftp.attrs(reqId, attrs);
469
+ this.debugEnd('SFTP lstat path succeed', s);
459
470
  }
460
471
  catch (err) {
461
- logger_1.default.debug('SFTP lstat path failed');
462
- logger_1.default.debug(err);
463
472
  this.sftp.status(reqId, STATUS_CODE.FAILURE);
473
+ this.debugEnd('SFTP lstat path failed', s, err);
464
474
  }
465
475
  }
466
476
  destroy() {
@@ -16,6 +16,7 @@ class ServerSsh extends events_1.default {
16
16
  this.server = new ssh2_1.default.Server({
17
17
  keepAlive: true,
18
18
  hostKeys: [hostKey],
19
+ highWaterMark: 16 * 1024 * 1024,
19
20
  ident: 'ssh2 server',
20
21
  }, (client) => this.processClient(client));
21
22
  this.server.listen();
@@ -71,6 +72,8 @@ class ServerSsh extends events_1.default {
71
72
  session.on('close', closeSession);
72
73
  session.on('end', closeSession);
73
74
  session.on('exec', (accept, reject, info) => {
75
+ logger_js_1.default.debug('sftp exec');
76
+ const s = process.hrtime();
74
77
  if (!info.command) {
75
78
  if (reject)
76
79
  reject();
@@ -89,6 +92,9 @@ class ServerSsh extends events_1.default {
89
92
  stream.end();
90
93
  stream = null;
91
94
  }
95
+ const [seconds, nano] = process.hrtime(s);
96
+ const ms = seconds * 1000 + nano / 1000 / 1000;
97
+ logger_js_1.default.debug(`sftp exec ends: ${ms}ms`);
92
98
  });
93
99
  });
94
100
  session.on('env', (accept, reject, info) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.9.5-dev",
4
+ "version": "1.9.6-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {