From 00a67cc4a9054360bbca8ebcda85fa91e0d179ee Mon Sep 17 00:00:00 2001 From: Elliot Sayes Date: Thu, 12 Dec 2024 17:07:22 +0800 Subject: [PATCH] Add check for on/after EOF --- extensions/weavedrive/src/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/extensions/weavedrive/src/index.js b/extensions/weavedrive/src/index.js index fbb12c38..4efa3fce 100644 --- a/extensions/weavedrive/src/index.js +++ b/extensions/weavedrive/src/index.js @@ -202,6 +202,13 @@ module.exports = function weaveDrive (mod, FS) { mod.HEAP8.set(stream.node.contents.subarray(0, toRead), dstPtr) return toRead } + + // console.log(`stream.node.total_size: ${stream.node.total_size}, stream.position: ${stream.position}, to_read: ${to_read}`) + if (stream.position >= stream.node.total_size) { + // console.log("WeaveDrive: EOF reached.") + return 0; + } + // Satisfy what we can with the cache first let bytesRead = this.readFromCache(stream, dstPtr, toRead) stream.position += bytesRead