diff --git a/src/renderer/ProcessHandlerWin.js b/src/renderer/ProcessHandlerWin.js index 885400d..c031a53 100644 --- a/src/renderer/ProcessHandlerWin.js +++ b/src/renderer/ProcessHandlerWin.js @@ -46,8 +46,6 @@ class ProcessHandlerWin { ] } - console.log(cmdArgs) - if (conn.authType === 'password' || conn.authType === 'password-ask') { cmdArgs.push('-oPreferredAuthentications=password') cmdArgs.push('-opassword_stdin') @@ -119,6 +117,44 @@ class ProcessHandlerWin { }) }) } + + getLastSpawnedProcess () { + return new Promise((resolve, reject) => { + exec(`wmic process where '(name="sshfs.exe")' get processid, creationdate /value`, (err, stdout) => { + if (!err) { + let data = stdout.toString().trim().split('\n') + let pid = null + let creationDate = null + + data.forEach(item => { + let itemParts = item.split('=') + + let key = itemParts[0].trim().toLowerCase() + let value = itemParts[1].trim().toLowerCase() + + if (key === 'processid') { + pid = parseInt(value) + } + + if (key === 'creationdate') { + let year = parseInt(value.substr(0, 4)) + let month = parseInt(value.substr(4, 2)) - 1 + let day = parseInt(value.substr(6, 2)) + let hours = parseInt(value.substr(8, 2)) + let minutes = parseInt(value.substr(10, 2)) + let seconds = parseInt(value.substr(13, 2)) + + creationDate = new Date(year, month, day, hours, minutes, seconds) + } + }) + + resolve({ pid, creationDate }) + } else { + reject(new Error('Process not found')) + } + }) + }) + } } export default ProcessHandlerWin diff --git a/src/renderer/ProcessManager.js b/src/renderer/ProcessManager.js index da8cafc..9dfede7 100644 --- a/src/renderer/ProcessManager.js +++ b/src/renderer/ProcessManager.js @@ -17,6 +17,10 @@ class ProcessManager extends EventEmitter { } create (conn) { + this.timeoutTimer = setTimeout(() => { + this.emit('timeout', conn) + }, (this.processHandler.settings.processTrackTimeout * 1000)) + return new Promise((resolve, reject) => { this.processHandler.create(conn).then((pid, process) => { this.emit('created', { @@ -32,6 +36,8 @@ class ProcessManager extends EventEmitter { resolve(pid) }).catch(error => { reject(error) + }).finally(() => { + clearTimeout(this.timeoutTimer) }) }) } @@ -79,6 +85,10 @@ class ProcessManager extends EventEmitter { exists (pid) { return this.processHandler.exists(pid) } + + getLastSpawnedProcess () { + return this.processHandler.getLastSpawnedProcess() + } } const settings = store.state.Settings.settings diff --git a/src/renderer/components/MainWindow/index.vue b/src/renderer/components/MainWindow/index.vue index 2a9a977..e2436ee 100644 --- a/src/renderer/components/MainWindow/index.vue +++ b/src/renderer/components/MainWindow/index.vue @@ -47,6 +47,7 @@ diff --git a/src/renderer/components/SettingsWindow/index.vue b/src/renderer/components/SettingsWindow/index.vue index 4c41755..46110e2 100644 --- a/src/renderer/components/SettingsWindow/index.vue +++ b/src/renderer/components/SettingsWindow/index.vue @@ -6,6 +6,11 @@ +