mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-05 02:50:00 +00:00
defer tempfile cleanup
This commit is contained in:
parent
5f86e101df
commit
4675b7521e
@ -50,18 +50,17 @@ export class SSHService {
|
|||||||
}
|
}
|
||||||
const args = [await this.getWinSCPURI(session.profile, undefined, session.authUsername ?? undefined)]
|
const args = [await this.getWinSCPURI(session.profile, undefined, session.authUsername ?? undefined)]
|
||||||
|
|
||||||
|
let tmpFile: tmp.FileResult|null = null
|
||||||
if (session.activePrivateKey) {
|
if (session.activePrivateKey) {
|
||||||
const tmpFile = await tmp.file()
|
tmpFile = await tmp.file()
|
||||||
const privateKey = await sshpk.parsePrivateKey(session.activePrivateKey, 'auto')/* .toString('putty') */
|
const privateKey = await sshpk.parsePrivateKey(session.activePrivateKey, 'auto')/* .toString('putty') */
|
||||||
const forgePrivateKey = forge.pki.decryptRsaPrivateKey(privateKey.toString('pem'))
|
const forgePrivateKey = forge.pki.decryptRsaPrivateKey(privateKey.toString('pem'))
|
||||||
const ppk = forge.ssh.privateKeyToPutty(forgePrivateKey)
|
const ppk = forge.ssh.privateKeyToPutty(forgePrivateKey)
|
||||||
await fs.writeFile(tmpFile.path, ppk)
|
await fs.writeFile(tmpFile.path, ppk)
|
||||||
args.push(`/privatekey=${tmpFile.path}`)
|
args.push(`/privatekey=${tmpFile.path}`)
|
||||||
setTimeout(() => {
|
|
||||||
tmpFile.cleanup()
|
|
||||||
}, 5000)
|
|
||||||
}
|
}
|
||||||
this.platform.exec(path, args)
|
await this.platform.exec(path, args)
|
||||||
|
tmpFile?.cleanup()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ Tabby.registerMock('fs', {
|
|||||||
appendFile: () => null,
|
appendFile: () => null,
|
||||||
constants: {},
|
constants: {},
|
||||||
})
|
})
|
||||||
Tabby.registerMock('any-promise', Promise)
|
Tabby.registerMock('fs/promises', {})
|
||||||
Tabby.registerMock('tls', {})
|
Tabby.registerMock('tls', {})
|
||||||
Tabby.registerMock('module', {
|
Tabby.registerMock('module', {
|
||||||
globalPaths: [],
|
globalPaths: [],
|
||||||
@ -92,6 +92,7 @@ Tabby.registerMock('keytar', {
|
|||||||
})
|
})
|
||||||
Tabby.registerMock('@serialport/bindings', {})
|
Tabby.registerMock('@serialport/bindings', {})
|
||||||
Tabby.registerMock('@serialport/bindings-cpp', {})
|
Tabby.registerMock('@serialport/bindings-cpp', {})
|
||||||
|
Tabby.registerMock('tmp', {})
|
||||||
|
|
||||||
Tabby.registerModule('net', {
|
Tabby.registerModule('net', {
|
||||||
Socket: SocketProxy,
|
Socket: SocketProxy,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user