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