From 24eb30cc8ba2adfbdf95b10e9c6c771961e6e1ea Mon Sep 17 00:00:00 2001 From: klockky Date: Thu, 25 Jun 2026 16:08:33 +0300 Subject: [PATCH] =?UTF-8?q?fix(db):=20=D0=B1=D0=B0=D0=BD=D0=B4=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=D0=B9=20SQLite=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7=20?= =?UTF-8?q?FFI=20=E2=80=94=20UPSERT=20=D0=BF=D0=B0=D0=B4=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BD=D0=B0=20Android=209=20=D0=B8=20=D1=81=D1=82=D0=B0=D1=80?= =?UTF-8?q?=D1=88=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-android-fcm.yml | 2 +- .github/workflows/build-android.yml | 2 +- android/gradle.properties | 4 ++++ lib/core/storage/app_database.dart | 13 +++++++++---- pubspec.yaml | 1 - 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-android-fcm.yml b/.github/workflows/build-android-fcm.yml index 7603c83..f3f8718 100644 --- a/.github/workflows/build-android-fcm.yml +++ b/.github/workflows/build-android-fcm.yml @@ -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 diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index 1b5417a..3d7f042 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -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 diff --git a/android/gradle.properties b/android/gradle.properties index 492b2f1..0d35563 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -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 diff --git a/lib/core/storage/app_database.dart b/lib/core/storage/app_database.dart index ba1ba67..63640cf 100644 --- a/lib/core/storage/app_database.dart +++ b/lib/core/storage/app_database.dart @@ -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 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? _initCompleter; @@ -162,7 +166,7 @@ class AppDatabase { final dir = await getApplicationSupportDirectory(); return dir.path; } - return getDatabasesPath(); + return _mobileDbDir ??= await databaseFactorySqflitePlugin.getDatabasesPath(); } static Future _migrateLegacyDb(String target) async { @@ -181,6 +185,7 @@ class AppDatabase { static Future _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( diff --git a/pubspec.yaml b/pubspec.yaml index 78963af..f86de49 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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