fix: ensure we check file system if no API key loaded

This commit is contained in:
Alexis Tyler
2021-03-16 08:45:31 +10:30
parent a2b08d28a4
commit 58ebec7d28
2 changed files with 32 additions and 28 deletions

View File

@@ -258,12 +258,7 @@ export class ApiManager extends EventEmitter {
return keyObject[0];
}
private async getLock() {
this.lock ??= new Mutex();
return this.lock;
}
private async checkKey(filePath: string, force = false) {
async checkKey(filePath: string, force = false) {
const lock = await this.getLock();
await lock.runExclusive(async () => {
apiManagerLogger.debug('Checking API key for validity.');
@@ -302,6 +297,11 @@ export class ApiManager extends EventEmitter {
this.expire('my_servers');
});
}
private async getLock() {
this.lock ??= new Mutex();
return this.lock;
}
}
export const apiManager = new ApiManager();