File tree Expand file tree Collapse file tree 6 files changed +53
-4
lines changed
lib/src/wasm/vfs/async_opfs Expand file tree Collapse file tree 6 files changed +53
-4
lines changed Original file line number Diff line number Diff line change
1
+ ## 2.6.1
2
+
3
+ - Fix out-of-bound reads in the ` xWrite ` implementation of the OPFS-locks based
4
+ file-system implementation when writing more than 64 KiB in one operation.
5
+
1
6
## 2.6.0
2
7
3
8
- Add ` SimpleOpfsFileSystem.deleteFromStorage ` to delete OPFS-based file
Original file line number Diff line number Diff line change @@ -202,9 +202,11 @@ class WasmFile extends BaseVfsFile {
202
202
// buffer would otherwise overflow.
203
203
final bytesToWrite = min (MessageSerializer .dataSize, remainingBytes);
204
204
205
- final subBuffer = bytesToWrite == remainingBytes
206
- ? buffer
207
- : buffer.buffer.asUint8List (buffer.offsetInBytes, bytesToWrite);
205
+ final subBuffer =
206
+ (bytesToWrite == remainingBytes && totalBytesWritten == 0 )
207
+ ? buffer
208
+ : buffer.buffer.asUint8List (
209
+ buffer.offsetInBytes + totalBytesWritten, bytesToWrite);
208
210
vfs.serializer.byteView.set (subBuffer, 0 );
209
211
210
212
vfs._runInWorker (WorkerOperation .xWrite,
Original file line number Diff line number Diff line change 1
1
name : sqlite3
2
2
description : Provides lightweight yet convenient bindings to SQLite by using dart:ffi
3
- version : 2.6.0
3
+ version : 2.6.1
4
4
homepage : https://github.com/simolus3/sqlite3.dart/tree/main/sqlite3
5
5
issue_tracker : https://github.com/simolus3/sqlite3.dart/issues
6
6
Original file line number Diff line number Diff line change @@ -181,6 +181,16 @@ void main() {
181
181
await driver.assertFile (false );
182
182
}
183
183
});
184
+
185
+ test ('check large write and read' , () async {
186
+ await driver.openDatabase (
187
+ implementation: (storage, access),
188
+ onlyOpenVfs: true ,
189
+ );
190
+ await driver.assertFile (false );
191
+
192
+ await driver.checkReadWrite ();
193
+ });
184
194
}
185
195
});
186
196
}
Original file line number Diff line number Diff line change @@ -209,6 +209,14 @@ class TestWebDriver {
209
209
}
210
210
}
211
211
212
+ Future <void > checkReadWrite () async {
213
+ final result =
214
+ await driver.executeAsync ('check_read_write("", arguments[0])' , []);
215
+ if (result != null ) {
216
+ throw 'check_read_write() failed: $result ' ;
217
+ }
218
+ }
219
+
212
220
Future <void > delete (StorageMode mode) async {
213
221
await driver
214
222
.executeAsync ('delete_db(arguments[0], arguments[1])' , [mode.name]);
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import 'dart:convert';
2
2
import 'dart:html' ;
3
3
import 'dart:js_interop' ;
4
4
import 'dart:js_interop_unsafe' ;
5
+ import 'dart:typed_data' ;
5
6
6
7
import 'package:sqlite3_web/sqlite3_web.dart' ;
7
8
@@ -64,6 +65,29 @@ void main() {
64
65
.deleteDatabase (name: databaseName, storage: storage);
65
66
return true .toJS;
66
67
});
68
+ _addCallbackForWebDriver ('check_read_write' , (arg) async {
69
+ final vfs = database! .fileSystem;
70
+
71
+ final bytes = Uint8List (1024 * 128 );
72
+ for (var i = 0 ; i < 128 ; i++ ) {
73
+ bytes[i * 1024 ] = i;
74
+ }
75
+
76
+ await vfs.writeFile (FileType .database, bytes);
77
+ await vfs.flush ();
78
+ final result = await vfs.readFile (FileType .database);
79
+ if (result.length != bytes.length) {
80
+ return 'length mismatch' .toJS;
81
+ }
82
+
83
+ for (var i = 0 ; i < 128 ; i++ ) {
84
+ if (result[i * 1024 ] != i) {
85
+ return 'mismatch, i=$i , byte ${result [i * 1024 ]}' .toJS;
86
+ }
87
+ }
88
+
89
+ return null ;
90
+ });
67
91
68
92
document.getElementById ('selfcheck' )? .onClick.listen ((event) async {
69
93
print ('starting' );
You can’t perform that action at this time.
0 commit comments