Skip to content

Commit 414d5d6

Browse files
committed
WIP
1 parent bae9441 commit 414d5d6

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

src/EncryptedFS.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,12 @@ class EncryptedFS {
9393
logger?: Logger;
9494
fresh?: boolean;
9595
}): Promise<EncryptedFS> {
96-
let crypto: {
97-
key: Buffer,
98-
ops: Crypto
99-
} | undefined;
96+
let crypto:
97+
| {
98+
key: Buffer;
99+
ops: Crypto;
100+
}
101+
| undefined;
100102
if (db == null) {
101103
crypto = {
102104
key: dbKey!,
@@ -256,7 +258,7 @@ class EncryptedFS {
256258
} = {}): Promise<void> {
257259
this.logger.info(`Starting ${this.constructor.name}`);
258260
if (this.chrootParent == null) {
259-
if (this.crypto != null) {
261+
if (this.crypto != null) {
260262
await this.db.start({ crypto: this.crypto, fresh });
261263
}
262264
await this.iNodeMgr.start({ fresh });
@@ -347,7 +349,9 @@ class EncryptedFS {
347349
});
348350
// Chrooted EFS shares all of the dependencies
349351
// This means the dependencies are already in running state
350-
const efsChrooted = new EncryptedFS({
352+
const efsChrooted = new (this.constructor as new (
353+
...params: ConstructorParameters<typeof EncryptedFS>
354+
) => this)({
351355
db: this.db,
352356
iNodeMgr: this.iNodeMgr,
353357
fdMgr: this.fdMgr,

src/inodes/INodeManager.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class INodeManager {
207207
): ResourceAcquire<DBTransaction> {
208208
return async () => {
209209
const [transactionRelease, tran] = await this.db.transaction()();
210-
await tran!.lock(...inos.map(i => i.toString()));
210+
await tran!.lock(...inos.map((i) => i.toString()));
211211
return [transactionRelease, tran];
212212
};
213213
}
@@ -221,7 +221,9 @@ class INodeManager {
221221
): Promise<T> {
222222
const f = params.pop() as (tran: DBTransaction) => Promise<T>;
223223
return await this.db.withTransactionF(async (tran) => {
224-
await tran.lock(...(params as Array<INodeIndex>).map(i => i.toString()));
224+
await tran.lock(
225+
...(params as Array<INodeIndex>).map((i) => i.toString()),
226+
);
225227
return f(tran);
226228
});
227229
}
@@ -237,7 +239,9 @@ class INodeManager {
237239
tran: DBTransaction,
238240
) => AsyncGenerator<T, TReturn, TNext>;
239241
return this.db.withTransactionG(async function* (tran) {
240-
await tran.lock(...(params as Array<INodeIndex>).map(i => i.toString()));
242+
await tran.lock(
243+
...(params as Array<INodeIndex>).map((i) => i.toString()),
244+
);
241245
return yield* g(tran);
242246
});
243247
}
@@ -266,7 +270,10 @@ class INodeManager {
266270
return withF(
267271
[this.inoAllocation(navigated), this.db.transaction()],
268272
async ([ino, tran]) => {
269-
await tran.lock(ino.toString(), ...(params as Array<INodeIndex>).map(i => i.toString()));
273+
await tran.lock(
274+
ino.toString(),
275+
...(params as Array<INodeIndex>).map((i) => i.toString()),
276+
);
270277
return f(ino, tran);
271278
},
272279
);
@@ -302,7 +309,10 @@ class INodeManager {
302309
return withG(
303310
[this.inoAllocation(navigated), this.db.transaction()],
304311
async function* ([ino, tran]) {
305-
await tran.lock(ino.toString(), ...(params as Array<INodeIndex>).map(i => i.toString()));
312+
await tran.lock(
313+
ino.toString(),
314+
...(params as Array<INodeIndex>).map((i) => i.toString()),
315+
);
306316
return yield* g(ino, tran);
307317
},
308318
);

tests/EncryptedFS.concurrent.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4037,11 +4037,8 @@ describe(`${EncryptedFS.name} Concurrency`, () => {
40374037
results.every((result) => {
40384038
return (
40394039
result.status === 'fulfilled' &&
4040-
(
4041-
(Array.isArray(result.value) && result.value.length === 0)
4042-
||
4043-
result.value === undefined
4044-
)
4040+
((Array.isArray(result.value) && result.value.length === 0) ||
4041+
result.value === undefined)
40454042
);
40464043
})
40474044
) {

0 commit comments

Comments
 (0)