diff options
author | stephan <stephan@noemail.net> | 2022-09-17 23:47:20 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-09-17 23:47:20 +0000 |
commit | 5f4ad926817650b919ef1a9a987b8b70f906e9d9 (patch) | |
tree | 8d52c31e043d8298caefb616e5301a102ea8e1e5 /ext/wasm/sqlite3-opfs-async-proxy.js | |
parent | 8200a6d8d7685ab252667768a4c291f1f0e9993c (diff) | |
download | sqlite-5f4ad926817650b919ef1a9a987b8b70f906e9d9.tar.gz sqlite-5f4ad926817650b919ef1a9a987b8b70f906e9d9.zip |
Correct OPFS xRead() and xWrite() impls and add a very basic sanity test for them.
FossilOrigin-Name: cd06cc670029763955cf60ffcf944b36d41cb005b859d9b9fd0eea1b6741d0e9
Diffstat (limited to 'ext/wasm/sqlite3-opfs-async-proxy.js')
-rw-r--r-- | ext/wasm/sqlite3-opfs-async-proxy.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/ext/wasm/sqlite3-opfs-async-proxy.js b/ext/wasm/sqlite3-opfs-async-proxy.js index 4a60e8aa1..58498e006 100644 --- a/ext/wasm/sqlite3-opfs-async-proxy.js +++ b/ext/wasm/sqlite3-opfs-async-proxy.js @@ -259,10 +259,10 @@ const vfsAsyncImpls = { let rc = 0; const fh = __openFiles[fid]; try{ - const aRead = new Uint8array(fh.sab, n); + const aRead = new Uint8Array(fh.sab, 0, n); const nRead = fh.accessHandle.read(aRead, {at: offset}); if(nRead < n){/* Zero-fill remaining bytes */ - new Uint8array(fh.sab).fill(0, nRead, n); + new Uint8Array(fh.sab).fill(0, nRead, n); rc = state.sq3Codes.SQLITE_IOERR_SHORT_READ; } }catch(e){ @@ -302,7 +302,7 @@ const vfsAsyncImpls = { const fh = __openFiles[fid]; try{ affirmNotRO('xWrite', fh); - const nOut = fh.accessHandle.write(new UInt8Array(fh.sab, 0, n), {at: offset}); + const nOut = fh.accessHandle.write(new Uint8Array(fh.sab, 0, n), {at: offset}); rc = (nOut===n) ? 0 : state.sq3Codes.SQLITE_IOERR_WRITE; }catch(e){ error("xWrite():",e,fh); |