mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +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)
|
(k as string).startsWith(chunkPrefix)
|
||||||
) as string[];
|
) as string[];
|
||||||
}
|
}
|
||||||
|
async list(): Promise<string[]> {
|
||||||
|
return (await this.storage.keys()) as string[];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CacheStorageFileStore implements IFileStorage {
|
export class CacheStorageFileStore implements IFileStorage {
|
||||||
@@ -122,6 +125,12 @@ export class CacheStorageFileStore implements IFileStorage {
|
|||||||
.map((r) => r.url.slice(1));
|
.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) {
|
private toURL(chunkName: string) {
|
||||||
return `/${chunkName}`;
|
return `/${chunkName}`;
|
||||||
}
|
}
|
||||||
@@ -176,4 +185,8 @@ export class OriginPrivateFileSystem implements IFileStorage {
|
|||||||
await this.create();
|
await this.create();
|
||||||
return (await this.worker.listChunks(this.name, chunkPrefix)) || [];
|
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;
|
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>) {
|
private async safeOp<T>(chunkName: string, createPromise: () => Promise<T>) {
|
||||||
const lock = this.locks.get(chunkName);
|
const lock = this.locks.get(chunkName);
|
||||||
if (lock) await lock;
|
if (lock) await lock;
|
||||||
@@ -150,6 +158,9 @@ const workerModule = {
|
|||||||
},
|
},
|
||||||
async listChunks(directoryName: string, chunkPrefix: string) {
|
async listChunks(directoryName: string, chunkPrefix: string) {
|
||||||
return (await fileStores.get(directoryName)?.listChunks(chunkPrefix)) || [];
|
return (await fileStores.get(directoryName)?.listChunks(chunkPrefix)) || [];
|
||||||
|
},
|
||||||
|
async list(directoryName: string) {
|
||||||
|
return (await fileStores.get(directoryName)?.list()) || [];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export class StreamableFS implements IStreamableFS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async list(): Promise<string[]> {
|
async list(): Promise<string[]> {
|
||||||
return this.list();
|
return this.storage.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteFile(filename: string): Promise<boolean> {
|
async deleteFile(filename: string): Promise<boolean> {
|
||||||
|
|||||||
@@ -37,4 +37,5 @@ export interface IFileStorage {
|
|||||||
deleteChunk(chunkName: string): Promise<void>;
|
deleteChunk(chunkName: string): Promise<void>;
|
||||||
readChunk(chunkName: string): Promise<Uint8Array | undefined>;
|
readChunk(chunkName: string): Promise<Uint8Array | undefined>;
|
||||||
listChunks(chunkPrefix: string): Promise<string[]>;
|
listChunks(chunkPrefix: string): Promise<string[]>;
|
||||||
|
list(): Promise<string[]>;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user