From 6339a3ed9b156649a20aa06a5b3c96d52605ccfb Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Sat, 25 Jun 2016 14:13:26 +0200 Subject: [PATCH] update SshKey.store() --- ts/smartssh.classes.sshkey.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/ts/smartssh.classes.sshkey.ts b/ts/smartssh.classes.sshkey.ts index a93f5bc..908f0fc 100644 --- a/ts/smartssh.classes.sshkey.ts +++ b/ts/smartssh.classes.sshkey.ts @@ -73,15 +73,13 @@ export class SshKey { } store(dirPathArg?:string){ - let filePathObj = plugins.path.parse(dirPathArg); - if(filePathObj.ext = ".priv"){ - plugins.smartfile.memory.toFsSync(this._privKey,dirPathArg); - } else if (filePathObj.ext = ".pub"){ - plugins.smartfile.memory.toFsSync(this._pubKey,dirPathArg); - } else { //we assume we are given a directory as filePathArg, so we store the whole key - plugins.fs.ensureDirSync(filePathObj.dir); - this.store(plugins.path.join(filePathObj.dir,"key.priv")); // call this function recursivly - this.store(plugins.path.join(filePathObj.dir,"key.pub")); // call this function recursivly + plugins.fs.ensureDirSync(dirPathArg); + let fileNameBase = this.host; + if(this._privKey){ + plugins.smartfile.memory.toFsSync(this._privKey,plugins.path.join(dirPathArg,fileNameBase)); + }; + if (this._pubKey){ + plugins.smartfile.memory.toFsSync(this._pubKey,plugins.path.join(dirPathArg,fileNameBase + ".pub")); } } }