mirror of https://github.com/AMT-Cheif/drift.git
ffi: Create parent dir to avoid misuse errors (#731)
This commit is contained in:
parent
a2b28945d1
commit
ffc01e4516
|
@ -2,6 +2,7 @@
|
|||
|
||||
- New `DatabaseConnection.delayed` constructor to synchronously obtain a database connection
|
||||
that requires async setup. This can be useful when connecting to a `MoorIsolate`.
|
||||
- `VmDatabase`: Create directory of database file to avoid misuse errors from sqlite3.
|
||||
|
||||
## 3.3.1
|
||||
|
||||
|
|
|
@ -64,6 +64,13 @@ class _VmDelegate extends DatabaseDelegate {
|
|||
@override
|
||||
Future<void> open(QueryExecutorUser user) async {
|
||||
if (file != null) {
|
||||
// Create the parent directory if it doesn't exist. sqlite will emit
|
||||
// confusing misuse warnings otherwise
|
||||
final dir = file.parent;
|
||||
if (!dir.existsSync()) {
|
||||
dir.createSync(recursive: true);
|
||||
}
|
||||
|
||||
_db = sqlite3.open(file.path);
|
||||
} else {
|
||||
_db = sqlite3.openInMemory();
|
||||
|
|
Loading…
Reference in New Issue