Skip to content

Commit

Permalink
Merge pull request #123 from rhashimoto/fix-header-loading
Browse files Browse the repository at this point in the history
Fix file demo for multi-chunk header.
  • Loading branch information
rhashimoto authored Nov 1, 2023
2 parents 43b6ff4 + 36e7285 commit 56628ce
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion demo/file/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ async function importDatabase(vfs, path, stream) {
let copyOffset = 0;
const header = new DataView(new ArrayBuffer(32));
for (const chunk of chunks) {
const src = chunk.subarray(0, header.byteLength - copyOffset);
const dst = new Uint8Array(header.buffer, copyOffset);
dst.set(chunk.subarray(0, header.byteLength - copyOffset));
dst.set(src);
copyOffset += src.byteLength;
}

if (new TextDecoder().decode(header.buffer.slice(0, 16)) !== DBFILE_MAGIC) {
Expand Down

0 comments on commit 56628ce

Please sign in to comment.