w-ftp 1.0.2 → 1.0.5

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.
@@ -27,7 +27,7 @@
27
27
 
28
28
  <nav >
29
29
 
30
- <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#ftpCheckFile">ftpCheckFile</a></li><li><a href="global.html#ftpConn">ftpConn</a></li><li><a href="global.html#ftpDownload">ftpDownload</a></li><li><a href="global.html#ftpLs">ftpLs</a></li><li><a href="global.html#ftpQuit">ftpQuit</a></li><li><a href="global.html#ftpStateFile">ftpStateFile</a></li><li><a href="global.html#ftpSyncToLocal">ftpSyncToLocal</a></li><li><a href="global.html#ftpSyncToRemote">ftpSyncToRemote</a></li><li><a href="global.html#ftpUpload">ftpUpload</a></li><li><a href="global.html#WFtp">WFtp</a></li></ul>
30
+ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#conn">conn</a></li><li><a href="global.html#download">download</a></li><li><a href="global.html#isFile">isFile</a></li><li><a href="global.html#isFolder">isFolder</a></li><li><a href="global.html#ls">ls</a></li><li><a href="global.html#quit">quit</a></li><li><a href="global.html#stateFile">stateFile</a></li><li><a href="global.html#syncToLocal">syncToLocal</a></li><li><a href="global.html#syncToRemote">syncToRemote</a></li><li><a href="global.html#upload">upload</a></li><li><a href="global.html#WFtp">WFtp</a></li></ul>
31
31
  </nav>
32
32
 
33
33
  <div id="main">
@@ -64,6 +64,7 @@ import fsTreeFolder from 'wsemi/src/fsTreeFolder.mjs'
64
64
  import fsIsFolder from 'wsemi/src/fsIsFolder.mjs'
65
65
  import fsIsFile from 'wsemi/src/fsIsFile.mjs'
66
66
  import fsCreateFolder from 'wsemi/src/fsCreateFolder.mjs'
67
+ import ot from 'dayjs'
67
68
  import Jsftp from './jsftp.js'
68
69
 
69
70
 
@@ -104,7 +105,7 @@ import Jsftp from './jsftp.js'
104
105
  * })
105
106
  *
106
107
  */
107
- async function ftpConn(opt = {}) {
108
+ async function conn(opt = {}) {
108
109
  return null
109
110
  }
110
111
 
@@ -143,7 +144,7 @@ async function ftpConn(opt = {}) {
143
144
  * })
144
145
  *
145
146
  */
146
- async function ftpLs(fdRemote = '.') {
147
+ async function ls(fdRemote = '.') {
147
148
  return null
148
149
  }
149
150
 
@@ -179,7 +180,7 @@ async function ftpLs(fdRemote = '.') {
179
180
  * console.log(err)
180
181
  * })
181
182
  */
182
- async function ftpQuit() {
183
+ async function quit() {
183
184
  return null
184
185
  }
185
186
 
@@ -217,7 +218,7 @@ async function ftpQuit() {
217
218
  * console.log(err)
218
219
  * })
219
220
  */
220
- async function ftpStateFile(fpRemote) {
221
+ async function stateFile(fpRemote) {
221
222
  return null
222
223
  }
223
224
 
@@ -243,8 +244,8 @@ async function ftpStateFile(fpRemote) {
243
244
  * password: st.up.password,
244
245
  * })
245
246
  *
246
- * r = await ftp.checkFile('./_test_upload_client/DECL_20210805055044.csv')
247
- * console.log('ftp.checkFile', r)
247
+ * r = await ftp.isFile('./_test_upload_client/DECL_20210805055044.csv')
248
+ * console.log('ftp.isFile', r)
248
249
  *
249
250
  * r = await ftp.quit()
250
251
  * console.log('ftp.quit', r)
@@ -255,7 +256,45 @@ async function ftpStateFile(fpRemote) {
255
256
  * console.log(err)
256
257
  * })
257
258
  */
258
- async function ftpCheckFile(fpRemote) {
259
+ async function isFile(fpRemote) {
260
+ return null
261
+ }
262
+
263
+
264
+ /**
265
+ * 確認伺服器指定資料夾是否存在
266
+ *
267
+ * @param {String} opt.fpRemote 輸入伺服器上指定資料夾字串
268
+ * @return {Promise} 回傳Promise,resolve回傳指定資料夾是否存在布林值,reject回傳錯誤訊息
269
+ * @example
270
+ * import WFtp from './src/WFtp.mjs'
271
+ *
272
+ * async function test() {
273
+ * let r
274
+ *
275
+ * let ftp = WFtp()
276
+ * // console.log('ftp', ftp)
277
+ *
278
+ * await ftp.conn({
279
+ * hostname: st.up.hostname,
280
+ * port: st.up.port,
281
+ * username: st.up.username,
282
+ * password: st.up.password,
283
+ * })
284
+ *
285
+ * r = await ftp.isFolder('./_test_upload_client')
286
+ * console.log('ftp.isFolder', r)
287
+ *
288
+ * r = await ftp.quit()
289
+ * console.log('ftp.quit', r)
290
+ *
291
+ * }
292
+ * test()
293
+ * .catch((err) => {
294
+ * console.log(err)
295
+ * })
296
+ */
297
+ async function isFolder(fpRemote) {
259
298
  return null
260
299
  }
261
300
 
@@ -297,7 +336,7 @@ async function ftpCheckFile(fpRemote) {
297
336
  * console.log(err)
298
337
  * })
299
338
  */
300
- async function ftpDownload(fpRemote, fpLocal, cbProcess = null) {
339
+ async function download(fpRemote, fpLocal, cbProcess = null) {
301
340
  return null
302
341
  }
303
342
 
@@ -339,7 +378,7 @@ async function ftpDownload(fpRemote, fpLocal, cbProcess = null) {
339
378
  * console.log(err)
340
379
  * })
341
380
  */
342
- async function ftpUpload(fpLocal, fpRemote, cbProcess) {
381
+ async function upload(fpLocal, fpRemote, cbProcess) {
343
382
  return null
344
383
  }
345
384
 
@@ -381,7 +420,7 @@ async function ftpUpload(fpLocal, fpRemote, cbProcess) {
381
420
  * console.log(err)
382
421
  * })
383
422
  */
384
- async function ftpSyncToLocal(fdRemote, fdLocal, cbProcess) {
423
+ async function syncToLocal(fdRemote, fdLocal, cbProcess) {
385
424
  return null
386
425
  }
387
426
 
@@ -423,7 +462,7 @@ async function ftpSyncToLocal(fdRemote, fdLocal, cbProcess) {
423
462
  * console.log(err)
424
463
  * })
425
464
  */
426
- async function ftpSyncToRemote(fdLocal, fdRemote, cbProcess) {
465
+ async function syncToRemote(fdLocal, fdRemote, cbProcess) {
427
466
  return null
428
467
  }
429
468
 
@@ -431,11 +470,11 @@ async function ftpSyncToRemote(fdLocal, fdRemote, cbProcess) {
431
470
  /**
432
471
  * 操作FTP,包含連線、下載、資料夾內檔案同步下載、上傳、資料夾內檔案同步上傳等功能
433
472
  *
434
- * @returns {Object} 回傳FTP操作物件,包含conn、ls、stateFile、checkFile、download、syncToLocal、syncToRemote、upload、quit。
473
+ * @returns {Object} 回傳FTP操作物件,包含conn、ls、stateFile、isFile、download、syncToLocal、syncToRemote、upload、quit。
435
474
  * @example
436
475
  * import WFtp from './src/WFtp.mjs'
437
476
  *
438
- * async function test_up() {
477
+ * async function test_dw() {
439
478
  * let r
440
479
  *
441
480
  * let ftp = WFtp()
@@ -448,46 +487,73 @@ async function ftpSyncToRemote(fdLocal, fdRemote, cbProcess) {
448
487
  * password: `{password}`,
449
488
  * })
450
489
  *
451
- * let fps = await ftp.ls('.')
452
- * console.log('ftp.ls', fps[0], fps.length)
490
+ * async function core() {
453
491
  *
454
- * r = await ftp.upload('./_test_upload_client/DECL_20210805055044.csv', './DECL_20210805055044.csv', (p) => {
455
- * console.log('ftp.upload p', p.name, p.progress)
456
- * })
457
- * console.log('ftp.upload', r)
492
+ * let fps = await ftp.ls('.')
493
+ * console.log('ftp.ls', fps[0], fps.length)
458
494
  *
459
- * r = await ftp.syncToRemote('./_test_upload_client', '.', (p) => {
460
- * console.log('ftp.syncToRemote p', p.name, p.progress)
461
- * })
462
- * console.log('ftp.syncToRemote', r)
495
+ * r = await ftp.download('./DECL_20210805055044.csv', './_test_download_client/DECL_20210805055044.csv', (p) => {
496
+ * console.log('ftp.download p', p.name, p.progress)
497
+ * })
498
+ * console.log('ftp.download', r)
499
+ *
500
+ * r = await ftp.syncToLocal('.', './_test_download_client', (p) => {
501
+ * console.log('ftp.syncToLocal p', p.name, p.progress)
502
+ * })
503
+ * console.log('ftp.syncToLocal', r)
504
+ *
505
+ * }
506
+ * await core()
507
+ * .catch((err) => {
508
+ * console.log(err)
509
+ * })
463
510
  *
464
511
  * r = await ftp.quit()
465
512
  * console.log('ftp.quit', r)
466
513
  *
467
514
  * }
468
- * test_up()
515
+ * test_dw()
469
516
  * .catch((err) => {
470
517
  * console.log(err)
471
518
  * })
472
519
  * // ftp.ls {
473
520
  * // name: 'DECL_202108.csv',
474
521
  * // type: 0,
475
- * // time: 1658366760000,
522
+ * // time: 1658302140000,
476
523
  * // size: '218690',
477
524
  * // owner: 'ftp',
478
525
  * // group: 'ftp',
479
526
  * // userPermissions: { read: true, write: true, exec: false },
480
527
  * // groupPermissions: { read: true, write: true, exec: false },
481
528
  * // otherPermissions: { read: true, write: true, exec: false }
482
- * // } 73
483
- * // ftp.upload p DECL_20210805055044.csv 75.71339448693362
484
- * // drain
485
- * // ftp.upload p DECL_20210805055044.csv 100
486
- * // ftp.upload ok
487
- * // ftp.syncToRemote { num: 0, files: [] }
529
+ * // } 74
530
+ * // ftp.download p DECL_20210805055044.csv 4.7320871554333515
531
+ * // ftp.download p DECL_20210805055044.csv 9.464174310866703
532
+ * // ftp.download p DECL_20210805055044.csv 14.196261466300053
533
+ * // ftp.download p DECL_20210805055044.csv 18.928348621733406
534
+ * // ftp.download p DECL_20210805055044.csv 23.660435777166754
535
+ * // ftp.download p DECL_20210805055044.csv 28.392522932600105
536
+ * // ftp.download p DECL_20210805055044.csv 33.12461008803346
537
+ * // ftp.download p DECL_20210805055044.csv 37.85669724346681
538
+ * // ftp.download p DECL_20210805055044.csv 42.58878439890016
539
+ * // ftp.download p DECL_20210805055044.csv 47.32087155433351
540
+ * // ftp.download p DECL_20210805055044.csv 52.05295870976686
541
+ * // ftp.download p DECL_20210805055044.csv 56.78504586520021
542
+ * // ftp.download p DECL_20210805055044.csv 61.517133020633565
543
+ * // ftp.download p DECL_20210805055044.csv 66.24922017606691
544
+ * // ftp.download p DECL_20210805055044.csv 70.98130733150026
545
+ * // ftp.download p DECL_20210805055044.csv 75.71339448693362
546
+ * // ftp.download p DECL_20210805055044.csv 80.44548164236697
547
+ * // ftp.download p DECL_20210805055044.csv 85.17756879780032
548
+ * // ftp.download p DECL_20210805055044.csv 89.90965595323367
549
+ * // ftp.download p DECL_20210805055044.csv 94.64174310866701
550
+ * // ftp.download p DECL_20210805055044.csv 99.37383026410038
551
+ * // ftp.download p DECL_20210805055044.csv 100
552
+ * // ftp.download ok
553
+ * // ftp.syncToLocal { num: 0, files: [] }
488
554
  * // ftp.quit { code: 221, text: '221 Goodbye.', isMark: false, isError: false }
489
555
  *
490
- * async function test_dw() {
556
+ * async function test_up() {
491
557
  * let r
492
558
  *
493
559
  * let ftp = WFtp()
@@ -500,81 +566,70 @@ async function ftpSyncToRemote(fdLocal, fdRemote, cbProcess) {
500
566
  * password: `{password}`,
501
567
  * })
502
568
  *
503
- * let fps = await ftp.ls('.')
504
- * console.log('ftp.ls', fps[0], fps.length)
569
+ * async function core() {
505
570
  *
506
- * r = await ftp.download('./DECL_20210805055044.csv', './_test_download_client/DECL_20210805055044.csv', (p) => {
507
- * console.log('ftp.download p', p.name, p.progress)
508
- * })
509
- * console.log('ftp.download', r)
571
+ * let fps = await ftp.ls('.')
572
+ * console.log('ftp.ls', fps[0], fps.length)
510
573
  *
511
- * r = await ftp.syncToLocal('.', './_test_download_client', (p) => {
512
- * console.log('ftp.syncToLocal p', p.name, p.progress)
513
- * })
514
- * console.log('ftp.syncToLocal', r)
574
+ * r = await ftp.upload('./_test_upload_client/DECL_20210805055044.csv', './DECL_20210805055044.csv', (p) => {
575
+ * console.log('ftp.upload p', p.name, p.progress)
576
+ * })
577
+ * console.log('ftp.upload', r)
578
+ *
579
+ * r = await ftp.syncToRemote('./_test_upload_client', '.', (p) => {
580
+ * console.log('ftp.syncToRemote p', p.name, p.progress)
581
+ * })
582
+ * console.log('ftp.syncToRemote', r)
583
+ *
584
+ * }
585
+ * await core()
586
+ * .catch((err) => {
587
+ * console.log(err)
588
+ * })
515
589
  *
516
590
  * r = await ftp.quit()
517
591
  * console.log('ftp.quit', r)
518
592
  *
519
593
  * }
520
- * test_dw()
594
+ * test_up()
521
595
  * .catch((err) => {
522
596
  * console.log(err)
523
597
  * })
524
598
  * // ftp.ls {
525
599
  * // name: 'DECL_202108.csv',
526
600
  * // type: 0,
527
- * // time: 1658302140000,
601
+ * // time: 1658366760000,
528
602
  * // size: '218690',
529
603
  * // owner: 'ftp',
530
604
  * // group: 'ftp',
531
605
  * // userPermissions: { read: true, write: true, exec: false },
532
606
  * // groupPermissions: { read: true, write: true, exec: false },
533
607
  * // otherPermissions: { read: true, write: true, exec: false }
534
- * // } 74
535
- * // ftp.download p DECL_20210805055044.csv 4.7320871554333515
536
- * // ftp.download p DECL_20210805055044.csv 9.464174310866703
537
- * // ftp.download p DECL_20210805055044.csv 14.196261466300053
538
- * // ftp.download p DECL_20210805055044.csv 18.928348621733406
539
- * // ftp.download p DECL_20210805055044.csv 23.660435777166754
540
- * // ftp.download p DECL_20210805055044.csv 28.392522932600105
541
- * // ftp.download p DECL_20210805055044.csv 33.12461008803346
542
- * // ftp.download p DECL_20210805055044.csv 37.85669724346681
543
- * // ftp.download p DECL_20210805055044.csv 42.58878439890016
544
- * // ftp.download p DECL_20210805055044.csv 47.32087155433351
545
- * // ftp.download p DECL_20210805055044.csv 52.05295870976686
546
- * // ftp.download p DECL_20210805055044.csv 56.78504586520021
547
- * // ftp.download p DECL_20210805055044.csv 61.517133020633565
548
- * // ftp.download p DECL_20210805055044.csv 66.24922017606691
549
- * // ftp.download p DECL_20210805055044.csv 70.98130733150026
550
- * // ftp.download p DECL_20210805055044.csv 75.71339448693362
551
- * // ftp.download p DECL_20210805055044.csv 80.44548164236697
552
- * // ftp.download p DECL_20210805055044.csv 85.17756879780032
553
- * // ftp.download p DECL_20210805055044.csv 89.90965595323367
554
- * // ftp.download p DECL_20210805055044.csv 94.64174310866701
555
- * // ftp.download p DECL_20210805055044.csv 99.37383026410038
556
- * // ftp.download p DECL_20210805055044.csv 100
557
- * // ftp.download ok
558
- * // ftp.syncToLocal { num: 0, files: [] }
608
+ * // } 73
609
+ * // ftp.upload p DECL_20210805055044.csv 75.71339448693362
610
+ * // ftp.upload p DECL_20210805055044.csv 100
611
+ * // ftp.upload ok
612
+ * // ftp.syncToRemote { num: 0, files: [] }
559
613
  * // ftp.quit { code: 221, text: '221 Goodbye.', isMark: false, isError: false }
560
614
  *
561
615
  */
562
616
  function WFtp() {
563
- let t = this
564
- t._ = {
565
- doc_ftpConn: ftpConn,
566
- doc_ftpLs: ftpLs,
567
- doc_ftpQuit: ftpQuit,
568
- doc_ftpStateFile: ftpStateFile,
569
- doc_ftpCheckFile: ftpCheckFile,
570
- doc_ftpDownload: ftpDownload,
571
- doc_ftpUpload: ftpUpload,
572
- doc_ftpSyncToLocal: ftpSyncToLocal,
573
- doc_ftpSyncToRemote: ftpSyncToRemote,
617
+ let doc = {
618
+ doc_conn: conn,
619
+ doc_ls: ls,
620
+ doc_quit: quit,
621
+ doc_stateFile: stateFile,
622
+ doc_isFile: isFile,
623
+ doc_isFolder: isFolder,
624
+ doc_download: download,
625
+ doc_upload: upload,
626
+ doc_syncToLocal: syncToLocal,
627
+ doc_syncToRemote: syncToRemote,
574
628
  }
575
629
 
576
630
  function WFtpCore() {
577
631
  let Ftp = null
632
+ let timeLimit = 1 * 60 * 1000 //1hr
578
633
 
579
634
 
580
635
  async function ftpConn(opt = {}) {
@@ -611,6 +666,18 @@ function WFtp() {
611
666
  return pm
612
667
  }
613
668
 
669
+ //timeLimit
670
+ let _timeLimit = get(opt, 'timeLimit')
671
+ if (isnum(_timeLimit)) {
672
+
673
+ //cint
674
+ _timeLimit = cint(_timeLimit)
675
+
676
+ //update
677
+ timeLimit = _timeLimit
678
+
679
+ }
680
+
614
681
  try {
615
682
  Ftp = new Jsftp({
616
683
  host: hostname, //hostname or ip
@@ -618,6 +685,7 @@ function WFtp() {
618
685
  user: username, // defaults to "anonymous"
619
686
  pass: password, // defaults to "@anonymous"
620
687
  })
688
+ Ftp.__doc__ = doc
621
689
  pm.resolve('ok')
622
690
  }
623
691
  catch (err) {
@@ -639,11 +707,26 @@ function WFtp() {
639
707
  return pm
640
708
  }
641
709
 
710
+ //timeLimit
711
+ let t = setTimeout(() => {
712
+ pm.reject(`timeout[${timeLimit}]`)
713
+ }, timeLimit)
714
+
642
715
  Ftp.ls(fdRemote, (err, res) => {
716
+
717
+ //clearTimeout
718
+ clearTimeout(t)
719
+
643
720
  if (err) {
644
721
  pm.reject(err)
645
722
  }
646
723
  else {
724
+ res = map(res, (v) => {
725
+ let d = ot(v.time) //jsfpt解析時間係基於ls, 其檔案變更時間精度只至分而沒有秒, 故無法提供精確的檔案變更時間
726
+ v.ctime = d.format('YYYY-MM-DDTHH:mm:ssZ') //添加UTC時間
727
+ v.isFolder = ftpIsFolderCore(v)
728
+ return v
729
+ })
647
730
  pm.resolve(res)
648
731
  }
649
732
  })
@@ -663,7 +746,29 @@ function WFtp() {
663
746
  return pm
664
747
  }
665
748
 
749
+ //timeLimit
750
+ let t = setTimeout(() => {
751
+
752
+ //destroy
753
+ Ftp.destroy()
754
+
755
+ //clear
756
+ Ftp = null
757
+
758
+ pm.reject(`timeout[${timeLimit}]`)
759
+ }, timeLimit)
760
+
666
761
  Ftp.raw('quit', (err, res) => {
762
+
763
+ //clearTimeout
764
+ clearTimeout(t)
765
+
766
+ //destroy
767
+ Ftp.destroy()
768
+
769
+ //clear
770
+ Ftp = null
771
+
667
772
  if (err) {
668
773
  pm.reject(err)
669
774
  }
@@ -696,13 +801,56 @@ function WFtp() {
696
801
  }
697
802
 
698
803
 
699
- async function ftpCheckFile(fpRemote) {
804
+ function ftpIsFolderCore(file) {
805
+
806
+ //check
807
+ if (!iseobj(file)) {
808
+ return false
809
+ }
810
+
811
+ //type
812
+ let type = get(file, 'type', -1)
813
+
814
+ //b
815
+ let b = type === 1
816
+
817
+ return b
818
+ }
819
+
820
+
821
+ function ftpIsFileCore(file) {
822
+
823
+ //check
824
+ if (!iseobj(file)) {
825
+ return false
826
+ }
827
+
828
+ //type
829
+ let type = get(file, 'type', -1)
830
+
831
+ //b
832
+ let b = type === 0
833
+
834
+ return b
835
+ }
836
+
837
+
838
+ async function ftpIsFolder(fpRemote) {
700
839
 
701
840
  //ftpStateFile
702
841
  let file = await ftpStateFile(fpRemote)
703
842
 
704
- //b
705
- let b = iseobj(file)
843
+ //ftpIsFolderCore
844
+ let b = ftpIsFolderCore(file)
845
+
846
+ return b
847
+ }
848
+
849
+
850
+ async function ftpIsFile(fpRemote) {
851
+
852
+ //ftpIsFileCore
853
+ let b = await ftpIsFileCore(fpRemote)
706
854
 
707
855
  return b
708
856
  }
@@ -743,6 +891,22 @@ function WFtp() {
743
891
  let file = await ftpStateFile(fpRemote)
744
892
  // console.log('file', file)
745
893
 
894
+ //ftpIsFileCore
895
+ let b = await ftpIsFileCore(file)
896
+ // console.log('b', b)
897
+
898
+ //check
899
+ if (!b) {
900
+ pm.reject(`fpRemote[${fpRemote}] is not a file`)
901
+ return pm
902
+ }
903
+
904
+ //check
905
+ if (!iseobj(file)) {
906
+ pm.reject(`fpRemote[${fpRemote}] does not have information`)
907
+ return pm
908
+ }
909
+
746
910
  //fileSize
747
911
  let fileSize = get(file, 'size')
748
912
 
@@ -754,10 +918,19 @@ function WFtp() {
754
918
  fileSize = cint(fileSize)
755
919
  // console.log('fileSize', fileSize)
756
920
 
921
+ //timeLimit
922
+ let t = setTimeout(() => {
923
+ pm.reject(`timeout[${timeLimit}]`)
924
+ }, timeLimit)
925
+
757
926
  Ftp.get(fpRemote, (err, socket) => {
758
927
 
759
928
  //check
760
929
  if (err) {
930
+
931
+ //clearTimeout
932
+ clearTimeout(t)
933
+
761
934
  pm.reject(err)
762
935
  }
763
936
 
@@ -795,6 +968,10 @@ function WFtp() {
795
968
 
796
969
  //on close
797
970
  socket.on('close', (err) => {
971
+
972
+ //clearTimeout
973
+ clearTimeout(t)
974
+
798
975
  if (err) {
799
976
  pm.reject(err)
800
977
  }
@@ -861,18 +1038,31 @@ function WFtp() {
861
1038
  // //createReadStream
862
1039
  // let reader = fs.createReadStream(fpLocal)
863
1040
 
1041
+ //timeLimit
1042
+ let t = setTimeout(() => {
1043
+ pm.reject(`timeout[${timeLimit}]`)
1044
+ }, timeLimit)
1045
+
864
1046
  let dss = 0
865
1047
  Ftp.put(bufferLocal, fpRemote, (err, buffer) => {
866
1048
  // console.log('Ftp.put', err, buffer)
867
1049
 
868
1050
  //check
869
1051
  if (err) {
1052
+
1053
+ //clearTimeout
1054
+ clearTimeout(t)
1055
+
870
1056
  pm.reject(err)
871
1057
  return
872
1058
  }
873
1059
 
874
1060
  //check
875
1061
  if (size(buffer) === 0) {
1062
+
1063
+ //clearTimeout
1064
+ clearTimeout(t)
1065
+
876
1066
  pm.resolve('ok')
877
1067
  return
878
1068
  }
@@ -906,11 +1096,9 @@ function WFtp() {
906
1096
 
907
1097
  //ftpLs
908
1098
  let fsRemote = await ftpLs(fdRemote)
909
- // fsRemote = map(fsRemote, (v) => {
910
- // let d = dayjs(v.time)
911
- // v.stat = d.format('YYYY-MM-DDTHH:mm:ss')
912
- // return v
913
- // })
1099
+ fsRemote = filter(fsRemote, (v) => {
1100
+ return !v.isFolder
1101
+ })
914
1102
  // console.log('fsRemote', fsRemote)
915
1103
 
916
1104
  //check fdLocal
@@ -1083,7 +1271,8 @@ function WFtp() {
1083
1271
  conn: ftpConn,
1084
1272
  ls: ftpLs,
1085
1273
  stateFile: ftpStateFile,
1086
- checkFile: ftpCheckFile,
1274
+ isFile: ftpIsFile,
1275
+ isFolder: ftpIsFolder,
1087
1276
  download: ftpDownload,
1088
1277
  syncToLocal: ftpSyncToLocal,
1089
1278
  syncToRemote: ftpSyncToRemote,
@@ -1111,7 +1300,7 @@ export default WFtp
1111
1300
  <br class="clear">
1112
1301
 
1113
1302
  <footer>
1114
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sat Jul 23 2022 21:29:33 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1303
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sat Sep 03 2022 15:35:03 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1115
1304
  </footer>
1116
1305
 
1117
1306
  <script>prettyPrint();</script>