From b73928109bb35590eaf262126d7e2742be770fbe Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Tue, 26 Apr 2016 05:09:03 +0200 Subject: [PATCH] improve sync triggering --- ts/smartssh.classes.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ts/smartssh.classes.ts b/ts/smartssh.classes.ts index a8b36d4..dc4fb3c 100644 --- a/ts/smartssh.classes.ts +++ b/ts/smartssh.classes.ts @@ -3,8 +3,8 @@ import plugins = require("./smartssh.plugins"); import helpers = require("./smartssh.classes.helpers"); export class ssh { - private sshConfig:sshConfig; - private sshDir:sshDir; + private sshConfig:sshConfig; // points to sshConfig class instance + private sshDir:sshDir; // points to sshDir class instance. private sshKeys:sshKey[]; //holds all ssh keys private sshSync:boolean; // if set to true, the ssh dir will be kept in sync automatically constructor(optionsArg:{sshDir?:string,sshSync?:boolean}={}){ @@ -29,13 +29,17 @@ export class ssh { removeKey(sshKeyArg:sshKey){ let keyIndex = helpers.getKeyIndex(sshKeyArg.host); this.sshKeys.splice(keyIndex,1); + this.sync(); }; replaceKey(sshKeyOldArg:sshKey,sshKeyNewArg:sshKey){ let keyIndex = helpers.getKeyIndex(sshKeyOldArg.host); this.sshKeys.splice(keyIndex,1,sshKeyNewArg); + this.sync(); }; sync(){ - this.sshDir.sync(this.sshConfig,this.sshKeys); //call sync method of sshDir class; + if(this.sshSync){ + this.sshDir.sync(this.sshConfig,this.sshKeys); // call sync method of sshDir class; + } }; }