1
0
mirror of https://github.com/bitwarden/directory-connector synced 2025-12-24 04:04:29 +00:00

Apply Prettier (#194)

This commit is contained in:
Oscar Hinton
2021-12-20 17:14:18 +01:00
committed by GitHub
parent 225073aa33
commit 096196fcd5
76 changed files with 6056 additions and 5208 deletions

View File

@@ -1,28 +1,34 @@
import * as lock from 'proper-lockfile';
import * as lock from "proper-lockfile";
import { LogService } from 'jslib-common/abstractions/log.service';
import { LogService } from "jslib-common/abstractions/log.service";
import { LowdbStorageService as LowdbStorageServiceBase } from 'jslib-node/services/lowdbStorage.service';
import { LowdbStorageService as LowdbStorageServiceBase } from "jslib-node/services/lowdbStorage.service";
import { Utils } from 'jslib-common/misc/utils';
import { Utils } from "jslib-common/misc/utils";
export class LowdbStorageService extends LowdbStorageServiceBase {
constructor(logService: LogService, defaults?: any, dir?: string, allowCache = false, private requireLock = false) {
super(logService, defaults, dir, allowCache);
}
constructor(
logService: LogService,
defaults?: any,
dir?: string,
allowCache = false,
private requireLock = false
) {
super(logService, defaults, dir, allowCache);
}
protected async lockDbFile<T>(action: () => T): Promise<T> {
if (this.requireLock && !Utils.isNullOrWhitespace(this.dataFilePath)) {
this.logService.info('acquiring db file lock');
return await lock.lock(this.dataFilePath, { retries: 3 }).then(release => {
try {
return action();
} finally {
release();
}
});
} else {
return action();
protected async lockDbFile<T>(action: () => T): Promise<T> {
if (this.requireLock && !Utils.isNullOrWhitespace(this.dataFilePath)) {
this.logService.info("acquiring db file lock");
return await lock.lock(this.dataFilePath, { retries: 3 }).then((release) => {
try {
return action();
} finally {
release();
}
});
} else {
return action();
}
}
}