Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fs: add support for getting actual file size

Abdullah Atta85484b176250
diff --git a/packages/streamable-fs/src/filehandle.ts b/packages/streamable-fs/src/filehandle.ts
index 7fb396eb5..6e52e7327 100644
--- a/packages/streamable-fs/src/filehandle.ts
+++ b/packages/streamable-fs/src/filehandle.ts
@@ -92,4 +92,14 @@ export default class FileHandle {
}
return new Blob(blobParts, { type: this.file.type });
}
+
+ async size() {
+ let size = 0;
+ for (let i = 0; i < this.file.chunks; ++i) {
+ const array = await this.readChunk(i);
+ if (!array) continue;
+ size += array.length;
+ }
+ return size;
+ }
}