A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fs: add chunkSize method for faster file size calculation
Abdullah Attacb52b390abb6
diff --git a/packages/streamable-fs/src/filehandle.ts b/packages/streamable-fs/src/filehandle.tsindex db1a20239..3d8054bd0 100644--- a/packages/streamable-fs/src/filehandle.ts+++ b/packages/streamable-fs/src/filehandle.ts@@ -101,9 +101,9 @@ export default class FileHandle {async size() {let size = 0;for (const chunk of this.chunks) {- const array = await this.storage.readChunk(chunk);- if (!array) continue;- size += array.length;+ const length = await this.storage.chunkSize(chunk);+ if (!length) throw new Error(`Found 0 byte sized chunk.`);+ size += length;}return size;}diff --git a/packages/streamable-fs/src/interfaces.ts b/packages/streamable-fs/src/interfaces.tsindex 7869546f1..69f7e65f8 100644--- a/packages/streamable-fs/src/interfaces.ts+++ b/packages/streamable-fs/src/interfaces.ts@@ -43,6 +43,7 @@ export interface IFileStorage {writeChunk(chunkName: string, data: Uint8Array): Promise<void>;deleteChunk(chunkName: string): Promise<void>;readChunk(chunkName: string): Promise<Uint8Array | undefined>;+ chunkSize(chunkName: string): Promise<number>;listChunks(chunkPrefix: string): Promise<string[]>;list(): Promise<string[]>;}