mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-25 06:52:35 +01:00
fix: Linux database
This commit is contained in:
parent
7ec349b980
commit
772ff33d8e
@ -2,6 +2,7 @@ import 'dart:ffi';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:isolate';
|
import 'dart:isolate';
|
||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:sqflite/sqflite.dart' show getDatabasesPath;
|
import 'package:sqflite/sqflite.dart' show getDatabasesPath;
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -64,22 +65,17 @@ Future<Database> constructDb(
|
|||||||
final isolate = (await receivePort.first as MoorIsolate);
|
final isolate = (await receivePort.first as MoorIsolate);
|
||||||
return Database.connect(await isolate.connect());
|
return Database.connect(await isolate.connect());
|
||||||
} else if (Platform.isLinux) {
|
} else if (Platform.isLinux) {
|
||||||
debugPrint('[Moor] using desktop moor');
|
debugPrint('[Moor] using Linux desktop moor');
|
||||||
open.overrideFor(OperatingSystem.linux, _openOnLinux);
|
final appDocDir = await getApplicationSupportDirectory();
|
||||||
return Database(moor.VmDatabase.memory());
|
return Database(moor.VmDatabase(File('${appDocDir.path}/$filename')));
|
||||||
} else if (Platform.isWindows) {
|
} else if (Platform.isWindows) {
|
||||||
debugPrint('[Moor] using desktop moor');
|
debugPrint('[Moor] using Windows desktop moor');
|
||||||
open.overrideFor(OperatingSystem.linux, _openOnWindows);
|
open.overrideFor(OperatingSystem.windows, _openOnWindows);
|
||||||
return Database(moor.VmDatabase.memory());
|
return Database(moor.VmDatabase.memory());
|
||||||
}
|
}
|
||||||
throw Exception('Platform not supported');
|
throw Exception('Platform not supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicLibrary _openOnLinux() {
|
|
||||||
final libraryNextToScript = File('/usr/lib/x86_64-linux-gnu/libsqlite3.so');
|
|
||||||
return DynamicLibrary.open(libraryNextToScript.path);
|
|
||||||
}
|
|
||||||
|
|
||||||
DynamicLibrary _openOnWindows() {
|
DynamicLibrary _openOnWindows() {
|
||||||
final script = File(Platform.script.toFilePath());
|
final script = File(Platform.script.toFilePath());
|
||||||
final libraryNextToScript = File('${script.path}/sqlite3.dll');
|
final libraryNextToScript = File('${script.path}/sqlite3.dll');
|
||||||
|
Loading…
Reference in New Issue
Block a user