ftp-folder-sync
Advanced tools
Comparing version 1.1.2 to 1.1.3
39
index.js
@@ -50,4 +50,7 @@ "use strict"; | ||
this.totalItemsToScan = 0; | ||
this.purgeFilesChecked = 0; | ||
this.removeDirList = []; | ||
this.dirRemovedErrorInfo = {}; | ||
this.stopping = false; | ||
this.purgeOutputTimer = 0; | ||
}; | ||
@@ -94,2 +97,4 @@ | ||
this.dirRemovedErrorInfo = {}; | ||
this.stopping = false; | ||
this.purgeFilesChecked = 0; | ||
}; | ||
@@ -128,7 +133,12 @@ | ||
FtpSync.prototype.disconnect = function () { | ||
this.client.close(); | ||
//force close | ||
try{ | ||
this.client.close(); | ||
}catch (e){ | ||
} | ||
}; | ||
FtpSync.prototype.reconnect = async function () { | ||
this.client.close(); | ||
this.disconnect(); | ||
await this.connect(); | ||
@@ -351,5 +361,2 @@ }; | ||
this.client.trackProgress((info) => { | ||
if (this.halt()) { | ||
return; | ||
} | ||
this.statusFtp = info; | ||
@@ -389,2 +396,5 @@ if (this.uploadSpeedTime == null) { | ||
} | ||
if (info.type !== "list" && this.halt()) { | ||
return; | ||
} | ||
}); | ||
@@ -420,3 +430,4 @@ for (let i = 0; i < this.batches.length; i++) { | ||
FtpSync.prototype.halt = function () { | ||
if (this.stop) { | ||
if (this.stop && !this.stopping) { | ||
this.stopping = true; | ||
this.disconnect(); | ||
@@ -471,2 +482,3 @@ return true; | ||
await this.client.cd(remoteDirPath); | ||
this.log('getting a list : '.remoteDirPath); | ||
list = await this.client.list(); | ||
@@ -501,2 +513,3 @@ } catch (err) { | ||
scanned: this.ftpScanCounter, | ||
localScanned: this.purgeFilesChecked, | ||
total: this.totalItemsToScan | ||
@@ -789,2 +802,3 @@ }); | ||
scanned: this.ftpScanCounter, | ||
localScanned: this.purgeFilesChecked, | ||
total: this.totalItemsToScan | ||
@@ -897,5 +911,16 @@ }); | ||
let mainDir = ""; | ||
this.fileIndexer.db.createReadStream({ keys: true, values: false }) | ||
.on('data', (file) => { | ||
this.purgeFilesChecked++; | ||
if(this.purgeOutputTimer < Date.now()){ | ||
this.purgeOutputTimer = Date.now()+1000; | ||
this.FTPPurgeStatus({ | ||
action: "ftp-purge-status", | ||
count: this.removeCounter, | ||
scanned: this.ftpScanCounter, | ||
localScanned: this.purgeFilesChecked, | ||
total: this.totalItemsToScan | ||
}); | ||
} | ||
mainDir = this.getMainDir(file); | ||
@@ -902,0 +927,0 @@ if (this.fileExists(mainDir)) { |
{ | ||
"name": "ftp-folder-sync", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
38774
1083