Skip to content

Commit 9b50403

Browse files
committed
fix: cache validation of system keys
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 9b125a7 commit 9b50403

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

apps/encryption/lib/Users/Setup.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@
99

1010
use OCA\Encryption\Crypto\Crypt;
1111
use OCA\Encryption\KeyManager;
12+
use OCP\ICache;
13+
use OCP\ICacheFactory;
1214

1315
class Setup {
16+
private readonly ICache $cache;
1417

1518
public function __construct(
1619
private Crypt $crypt,
1720
private KeyManager $keyManager,
21+
ICacheFactory $cacheFactory,
1822
) {
23+
$this->cache = $cacheFactory->createLocal('encryption-setup');
1924
}
2025

2126
/**
@@ -35,7 +40,10 @@ public function setupUser($uid, $password) {
3540
* make sure that all system keys exists
3641
*/
3742
public function setupSystem() {
38-
$this->keyManager->validateShareKey();
39-
$this->keyManager->validateMasterKey();
43+
if (!$this->cache->get('keys-validated')) {
44+
$this->keyManager->validateShareKey();
45+
$this->keyManager->validateMasterKey();
46+
$this->cache->set('keys-validated', true);
47+
}
4048
}
4149
}

0 commit comments

Comments
 (0)