Skip to content

Commit

Permalink
Merge pull request #22 from wdhongtw/feat-check-status-before-unlock
Browse files Browse the repository at this point in the history
Only trigger unlock command when the key is locked
  • Loading branch information
wdhongtw authored Oct 30, 2021
2 parents 007fc7a + 81f632e commit e68c9b7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e68c9b7

Please sign in to comment.