mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 22:49:45 +01:00
web: fix "too much recursion" error
This commit is contained in:
committed by
Abdullah Atta
parent
1b71edef45
commit
438d412ae9
@@ -57,6 +57,9 @@ export class IndexedDBFileStore implements IFileStorage {
|
||||
(k as string).startsWith(chunkPrefix)
|
||||
) as string[];
|
||||
}
|
||||
async list(): Promise<string[]> {
|
||||
return (await this.storage.keys()) as string[];
|
||||
}
|
||||
}
|
||||
|
||||
export class CacheStorageFileStore implements IFileStorage {
|
||||
@@ -122,6 +125,12 @@ export class CacheStorageFileStore implements IFileStorage {
|
||||
.map((r) => r.url.slice(1));
|
||||
}
|
||||
|
||||
async list(): Promise<string[]> {
|
||||
const cache = await this.getCache();
|
||||
const keys = await cache.keys();
|
||||
return keys.map((r) => r.url.slice(1));
|
||||
}
|
||||
|
||||
private toURL(chunkName: string) {
|
||||
return `/${chunkName}`;
|
||||
}
|
||||
@@ -176,4 +185,8 @@ export class OriginPrivateFileSystem implements IFileStorage {
|
||||
await this.create();
|
||||
return (await this.worker.listChunks(this.name, chunkPrefix)) || [];
|
||||
}
|
||||
async list(): Promise<string[]> {
|
||||
await this.create();
|
||||
return (await this.worker.list(this.name)) || [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +101,14 @@ class OriginPrivateFileStore implements IFileStorage {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
async list(): Promise<string[]> {
|
||||
const chunks: string[] = [];
|
||||
for await (const entry of this.directory.keys()) {
|
||||
chunks.push(entry);
|
||||
}
|
||||
return chunks;
|
||||
}
|
||||
|
||||
private async safeOp<T>(chunkName: string, createPromise: () => Promise<T>) {
|
||||
const lock = this.locks.get(chunkName);
|
||||
if (lock) await lock;
|
||||
@@ -150,6 +158,9 @@ const workerModule = {
|
||||
},
|
||||
async listChunks(directoryName: string, chunkPrefix: string) {
|
||||
return (await fileStores.get(directoryName)?.listChunks(chunkPrefix)) || [];
|
||||
},
|
||||
async list(directoryName: string) {
|
||||
return (await fileStores.get(directoryName)?.list()) || [];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user