Skip to content

Commit

Permalink
Fixed IndexedDB missing a cache
Browse files Browse the repository at this point in the history
The minimum core version needed is now v0.12.10
  • Loading branch information
james-pre committed Jun 3, 2024
1 parent 640415e commit 0aa57d2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
23 changes: 15 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"typescript": "5.2.2"
},
"peerDependencies": {
"@zenfs/core": "^0.12.5"
"@zenfs/core": "^0.12.10"
},
"keywords": [
"filesystem",
Expand Down
11 changes: 7 additions & 4 deletions src/IndexedDB.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Store } from '@zenfs/core/backends/store/store.js';
import { AsyncTransaction } from '@zenfs/core/backends/store/store.js';
import type { Backend, Ino } from '@zenfs/core';
import { Async, ErrnoError, StoreFS } from '@zenfs/core';
import type { Backend, Ino, SharedConfig } from '@zenfs/core';
import { Async, ErrnoError, InMemory, StoreFS } from '@zenfs/core';
import { convertException, type ConvertException } from './utils.js';

function wrap<T>(request: IDBRequest<T>): Promise<T> {
Expand Down Expand Up @@ -141,10 +141,13 @@ export const IndexedDB = {
}
},

async create(options: IndexedDBOptions) {
async create(options: IndexedDBOptions & Partial<SharedConfig>) {
const db = await createDB(options.storeName || 'zenfs', options.idbFactory);
const store = new IndexedDBStore(db);
const fs = new (Async(StoreFS) as typeof StoreFS)(store);
const fs = new (Async(StoreFS))(store);
if(!options?.disableAsyncCache) {
fs._sync = InMemory.create({ name: 'idb-cache' });
}
return fs;
},
} as const satisfies Backend<StoreFS, IndexedDBOptions>;

0 comments on commit 0aa57d2

Please sign in to comment.