fix(db): бандленый SQLite через FFI — UPSERT падал на Android 9 и старше
This commit is contained in:
@@ -34,7 +34,7 @@ jobs:
|
||||
- name: Setup Flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: '3.41.5'
|
||||
flutter-version: '3.44.3'
|
||||
channel: 'stable'
|
||||
|
||||
- name: Get dependencies
|
||||
|
||||
@@ -34,7 +34,7 @@ jobs:
|
||||
- name: Setup Flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: '3.41.5'
|
||||
flutter-version: '3.44.3'
|
||||
channel: 'stable'
|
||||
|
||||
- name: Get dependencies
|
||||
|
||||
@@ -2,3 +2,7 @@ org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m
|
||||
android.useAndroidX=true
|
||||
kotlin.incremental=false
|
||||
dev.steenbakker.mobile_scanner.useUnbundled=true
|
||||
# This builtInKotlin flag was added automatically by Flutter migrator
|
||||
android.builtInKotlin=false
|
||||
# This newDsl flag was added automatically by Flutter migrator
|
||||
android.newDsl=false
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:komet/core/storage/app_instance.dart';
|
||||
import 'package:komet/core/utils/logger.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:sqflite/sqflite.dart' show databaseFactorySqflitePlugin;
|
||||
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
||||
|
||||
class ProfileData {
|
||||
@@ -133,11 +134,14 @@ abstract class SyncKey {
|
||||
class AppDatabase {
|
||||
static Database? _db;
|
||||
|
||||
static String? _mobileDbDir;
|
||||
|
||||
static Future<void> init() async {
|
||||
if (Platform.isLinux || Platform.isWindows || Platform.isMacOS) {
|
||||
sqfliteFfiInit();
|
||||
databaseFactory = databaseFactoryFfi;
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
_mobileDbDir = await databaseFactorySqflitePlugin.getDatabasesPath();
|
||||
}
|
||||
sqfliteFfiInit();
|
||||
databaseFactory = databaseFactoryFfi;
|
||||
}
|
||||
|
||||
static Completer<Database>? _initCompleter;
|
||||
@@ -162,7 +166,7 @@ class AppDatabase {
|
||||
final dir = await getApplicationSupportDirectory();
|
||||
return dir.path;
|
||||
}
|
||||
return getDatabasesPath();
|
||||
return _mobileDbDir ??= await databaseFactorySqflitePlugin.getDatabasesPath();
|
||||
}
|
||||
|
||||
static Future<void> _migrateLegacyDb(String target) async {
|
||||
@@ -181,6 +185,7 @@ class AppDatabase {
|
||||
|
||||
static Future<Database> _open() async {
|
||||
final dbPath = await _databasesDir();
|
||||
await Directory(dbPath).create(recursive: true);
|
||||
final target = join(dbPath, 'komet${AppInstance.suffix}.db');
|
||||
await _migrateLegacyDb(target);
|
||||
return openDatabase(
|
||||
|
||||
@@ -70,7 +70,6 @@ dependencies:
|
||||
flutter_local_notifications: ^22.0.1
|
||||
flutter_inappwebview: ^6.1.5
|
||||
flutter_webrtc: ^1.5.2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
Reference in New Issue
Block a user