update SshKey.store()

This commit is contained in:
Philipp Kunz 2016-06-25 14:13:26 +02:00
parent bf27aaf167
commit 6339a3ed9b

View File

@ -73,15 +73,13 @@ export class SshKey {
} }
store(dirPathArg?:string){ store(dirPathArg?:string){
let filePathObj = plugins.path.parse(dirPathArg); plugins.fs.ensureDirSync(dirPathArg);
if(filePathObj.ext = ".priv"){ let fileNameBase = this.host;
plugins.smartfile.memory.toFsSync(this._privKey,dirPathArg); if(this._privKey){
} else if (filePathObj.ext = ".pub"){ plugins.smartfile.memory.toFsSync(this._privKey,plugins.path.join(dirPathArg,fileNameBase));
plugins.smartfile.memory.toFsSync(this._pubKey,dirPathArg); };
} else { //we assume we are given a directory as filePathArg, so we store the whole key if (this._pubKey){
plugins.fs.ensureDirSync(filePathObj.dir); plugins.smartfile.memory.toFsSync(this._pubKey,plugins.path.join(dirPathArg,fileNameBase + ".pub"));
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
} }
} }
} }