diff --git a/app/lib/app_init.dart b/app/lib/app_init.dart index 72d47d62..fd425be3 100644 --- a/app/lib/app_init.dart +++ b/app/lib/app_init.dart @@ -37,6 +37,7 @@ import 'package:nc_photos/platform/features.dart' as features; import 'package:nc_photos/platform/k.dart' as platform_k; import 'package:nc_photos/pref.dart'; import 'package:nc_photos/pref_util.dart' as pref_util; +import 'package:sqlite3_flutter_libs/sqlite3_flutter_libs.dart'; import 'package:visibility_detector/visibility_detector.dart'; enum InitIsolateType { @@ -54,11 +55,14 @@ Future init(InitIsolateType isolateType) async { } initLog(); + await _initDeviceInfo(); initDrift(); + if (isolateType == InitIsolateType.main) { + await _initDriftWorkaround(); + } _initKiwi(); await _initPref(); await _initAccountPrefs(); - await _initDeviceInfo(); _initEquatable(); if (features.isSupportSelfSignedCert) { _initSelfSignedCertManager(); @@ -117,6 +121,15 @@ void initDrift() { driftRuntimeOptions.debugPrint = (log) => debugPrint(log, wrapWidth: 1024); } +Future _initDriftWorkaround() async { + if (AndroidInfo().sdkInt < 24) { + _log.info("[_initDriftWorkaround] Workaround Android 6- bug"); + // see: https://github.com/flutter/flutter/issues/73318 and + // https://github.com/simolus3/drift/issues/895 + await applyWorkaroundToOpenSqlite3OnOldAndroidVersions(); + } +} + Future _initPref() async { final provider = PrefSharedPreferencesProvider(); await provider.init();