Skip to content

Commit

Permalink
WIP - #305 - expanding tests EOD
Browse files Browse the repository at this point in the history
  • Loading branch information
tegefaulkes committed Feb 24, 2022
1 parent c5d70d2 commit 48afda2
Show file tree
Hide file tree
Showing 3 changed files with 498 additions and 128 deletions.
2 changes: 1 addition & 1 deletion src/vaults/VaultInternal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type GRPCClientAgent from '../agent/GRPCClientAgent';
import type { POJO } from '../types';
import path from 'path';
import git from 'isomorphic-git';
import grpc from '@grpc/grpc-js';
import * as grpc from '@grpc/grpc-js';
import Logger from '@matrixai/logger';
import {
CreateDestroyStartStop,
Expand Down
13 changes: 13 additions & 0 deletions src/vaults/VaultManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class VaultManager {
await withF([this.getWriteLock(vaultId)], async () => {
await vaultAndLock.vault?.stop();
});
this.vaultMap.delete(vaultIdString);
}

// Need to figure out if this id thing is a good idea
Expand Down Expand Up @@ -804,6 +805,12 @@ class VaultManager {
if (vault != null) {
return vault;
}
// Only create if the vault state already exists
if ((await this.getVaultMeta(vaultId)) == null) {
throw new vaultsErrors.ErrorVaultsVaultUndefined(
`Vault ${vaultsUtils.encodeVaultId(vaultId)} doesn't exist`,
);
}
vault = await VaultInternal.createVaultInternal({
vaultId,
keyManager: this.keyManager,
Expand All @@ -827,6 +834,12 @@ class VaultManager {
let release;
try {
release = await lock.acquireWrite();
// Only create if the vault state already exists
if ((await this.getVaultMeta(vaultId)) == null) {
throw new vaultsErrors.ErrorVaultsVaultUndefined(
`Vault ${vaultsUtils.encodeVaultId(vaultId)} doesn't exist`,
);
}
vault = await VaultInternal.createVaultInternal({
vaultId,
keyManager: this.keyManager,
Expand Down
Loading

0 comments on commit 48afda2

Please sign in to comment.