fix(transcripts): complete short reads within the requested tail

This commit is contained in:
Afloat committed 2026-11-17 10:34:44 +08:00
1 parent 8abdf329ec
commit 5c7eeba436
2 files changed
+96 -1

No files matched your search

+6 -1
View File
@@ -22,7 +22,12 @@ function readFileTail(filePath, tailBytes, options = {}) {
}
const buffer = Buffer.alloc(length);
const bytesRead = fs.readSync(fd, buffer, 0, length, start);
let bytesRead = 0;
while (bytesRead < length) {
const count = fs.readSync(fd, buffer, bytesRead, length - bytesRead, start + bytesRead);
if (count === 0) break;
bytesRead += count;
}
return {
text: buffer.toString('utf8', 0, bytesRead),
truncated: start > 0,