From 81f632e9f8537ad75086c437e8064105811f9e1f Mon Sep 17 00:00:00 2001 From: Weida Hong Date: Sat, 30 Oct 2021 17:48:13 +0800 Subject: [PATCH] Only trigger unlock command when the key is locked --- src/extension.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/extension.ts b/src/extension.ts index dc9d01e..d2fb3cd 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -271,6 +271,12 @@ class KeyStatusManager { throw new Error('No key for current folder'); } + await this.syncStatus(); + if (await gpg.isKeyUnlocked(theKey.keygrip)) { + this.#logger.log(`Key is already unlocked, skip unlock request`); + return; + } + this.#logger.log(`Try to unlock current key: ${theKey.fingerprint}`); await gpg.unlockByKeyId(theKey.fingerprint, passphrase); await this.syncStatus();