mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-01-12 02:32:54 +01:00
fix: Open database on android
This commit is contained in:
parent
65ef2e4317
commit
fc84245555
@ -60,7 +60,6 @@ class FlutterFluffyBoxDatabase extends FluffyBoxDatabase {
|
|||||||
await db.execute('PRAGMA page_size = 8192');
|
await db.execute('PRAGMA page_size = 8192');
|
||||||
await db.execute('PRAGMA cache_size = 16384');
|
await db.execute('PRAGMA cache_size = 16384');
|
||||||
await db.execute('PRAGMA temp_store = MEMORY');
|
await db.execute('PRAGMA temp_store = MEMORY');
|
||||||
await db.execute('PRAGMA journal_mode = WAL');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<sqflite.Database> _openSqlDatabase(
|
static Future<sqflite.Database> _openSqlDatabase(
|
||||||
@ -69,24 +68,28 @@ class FlutterFluffyBoxDatabase extends FluffyBoxDatabase {
|
|||||||
) async {
|
) async {
|
||||||
final path = await _findDatabasePath(client);
|
final path = await _findDatabasePath(client);
|
||||||
try {
|
try {
|
||||||
|
late final sqflite.Database db;
|
||||||
if (Platform.isAndroid || Platform.isIOS) {
|
if (Platform.isAndroid || Platform.isIOS) {
|
||||||
final db = await sqflite.openDatabase(
|
db = await sqflite.openDatabase(
|
||||||
path,
|
path,
|
||||||
password: password,
|
password: password,
|
||||||
onConfigure: _onConfigure,
|
onConfigure: _onConfigure,
|
||||||
);
|
);
|
||||||
return db;
|
return db;
|
||||||
}
|
} else {
|
||||||
final db = await ffi.databaseFactoryFfi.openDatabase(
|
db = await ffi.databaseFactoryFfi.openDatabase(
|
||||||
path,
|
path,
|
||||||
options: sqflite.SqlCipherOpenDatabaseOptions(
|
options: sqflite.SqlCipherOpenDatabaseOptions(
|
||||||
password: password,
|
password: password,
|
||||||
onConfigure: _onConfigure,
|
onConfigure: _onConfigure,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
await db.execute('PRAGMA journal_mode = WAL');
|
||||||
return db;
|
return db;
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
File(path).delete();
|
File(path).delete();
|
||||||
|
Logs().w('Failed to open database. Delete file now...');
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user