mirror of
https://github.com/immich-app/immich.git
synced 2025-12-06 04:41:40 -08:00
Compare commits
1 Commits
feat/andro
...
shared-dat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9996a1ec3e |
@@ -39,7 +39,7 @@ class ImmichTestHelper {
|
||||
static Future<void> loadApp(WidgetTester tester) async {
|
||||
await EasyLocalization.ensureInitialized();
|
||||
// Clear all data from Isar (reuse existing instance if available)
|
||||
final (isar, drift, logDb) = await Bootstrap.initDB();
|
||||
final (isar, drift, logDb) = await Bootstrap.initDB(shareAcrossIsolates: true);
|
||||
await Bootstrap.initDomain(isar, drift, logDb);
|
||||
await Store.clear();
|
||||
await isar.writeTxn(() => isar.clear());
|
||||
|
||||
@@ -246,7 +246,7 @@ Future<void> backgroundSyncNativeEntrypoint() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
DartPluginRegistrant.ensureInitialized();
|
||||
|
||||
final (isar, drift, logDB) = await Bootstrap.initDB();
|
||||
final (isar, drift, logDB) = await Bootstrap.initDB(shareAcrossIsolates: false);
|
||||
await Bootstrap.initDomain(isar, drift, logDB, shouldBufferLogs: false);
|
||||
await BackgroundWorkerBgService(isar: isar, drift: drift, driftLogger: logDB).init();
|
||||
}
|
||||
|
||||
@@ -66,8 +66,14 @@ class IsarDatabaseRepository implements IDatabaseRepository {
|
||||
include: {'package:immich_mobile/infrastructure/entities/merged_asset.drift'},
|
||||
)
|
||||
class Drift extends $Drift implements IDatabaseRepository {
|
||||
Drift([QueryExecutor? executor])
|
||||
: super(executor ?? driftDatabase(name: 'immich', native: const DriftNativeOptions(shareAcrossIsolates: true)));
|
||||
Drift({QueryExecutor? executor, bool shareAcrossIsolates = true})
|
||||
: super(
|
||||
executor ??
|
||||
driftDatabase(
|
||||
name: 'immich',
|
||||
native: DriftNativeOptions(shareAcrossIsolates: shareAcrossIsolates),
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
int get schemaVersion => 10;
|
||||
|
||||
@@ -7,9 +7,13 @@ import 'logger_db.repository.drift.dart';
|
||||
|
||||
@DriftDatabase(tables: [LogMessageEntity])
|
||||
class DriftLogger extends $DriftLogger implements IDatabaseRepository {
|
||||
DriftLogger([QueryExecutor? executor])
|
||||
DriftLogger({QueryExecutor? executor, bool shareAcrossIsolates = true})
|
||||
: super(
|
||||
executor ?? driftDatabase(name: 'immich_logs', native: const DriftNativeOptions(shareAcrossIsolates: true)),
|
||||
executor ??
|
||||
driftDatabase(
|
||||
name: 'immich_logs',
|
||||
native: DriftNativeOptions(shareAcrossIsolates: shareAcrossIsolates),
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
|
||||
@@ -42,7 +42,7 @@ import 'package:worker_manager/worker_manager.dart';
|
||||
|
||||
void main() async {
|
||||
ImmichWidgetsBinding();
|
||||
final (isar, drift, logDb) = await Bootstrap.initDB();
|
||||
final (isar, drift, logDb) = await Bootstrap.initDB(shareAcrossIsolates: true);
|
||||
await Bootstrap.initDomain(isar, drift, logDb);
|
||||
await initApp();
|
||||
// Warm-up isolate pool for worker manager
|
||||
|
||||
@@ -330,7 +330,7 @@ class BackgroundService {
|
||||
}
|
||||
|
||||
Future<bool> _onAssetsChanged() async {
|
||||
final (isar, drift, logDb) = await Bootstrap.initDB();
|
||||
final (isar, drift, logDb) = await Bootstrap.initDB(shareAcrossIsolates: false);
|
||||
await Bootstrap.initDomain(isar, drift, logDb);
|
||||
|
||||
final ref = ProviderContainer(
|
||||
|
||||
@@ -115,7 +115,7 @@ class BackupVerificationService {
|
||||
assert(tuple.deleteCandidates.length == tuple.originals.length);
|
||||
final List<Asset> result = [];
|
||||
BackgroundIsolateBinaryMessenger.ensureInitialized(tuple.rootIsolateToken);
|
||||
final (isar, drift, logDb) = await Bootstrap.initDB();
|
||||
final (isar, drift, logDb) = await Bootstrap.initDB(shareAcrossIsolates: true);
|
||||
await Bootstrap.initDomain(isar, drift, logDb);
|
||||
await tuple.fileMediaRepository.enableBackgroundAccess();
|
||||
final ApiService apiService = ApiService();
|
||||
|
||||
@@ -56,9 +56,9 @@ void configureFileDownloaderNotifications() {
|
||||
}
|
||||
|
||||
abstract final class Bootstrap {
|
||||
static Future<(Isar isar, Drift drift, DriftLogger logDb)> initDB() async {
|
||||
final drift = Drift();
|
||||
final logDb = DriftLogger();
|
||||
static Future<(Isar isar, Drift drift, DriftLogger logDb)> initDB({required bool shareAcrossIsolates}) async {
|
||||
final drift = Drift(shareAcrossIsolates: shareAcrossIsolates);
|
||||
final logDb = DriftLogger(shareAcrossIsolates: shareAcrossIsolates);
|
||||
|
||||
Isar? isar = Isar.getInstance();
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ Cancelable<T?> runInIsolateGentle<T>({
|
||||
BackgroundIsolateBinaryMessenger.ensureInitialized(token);
|
||||
DartPluginRegistrant.ensureInitialized();
|
||||
|
||||
final (isar, drift, logDb) = await Bootstrap.initDB();
|
||||
final (isar, drift, logDb) = await Bootstrap.initDB(shareAcrossIsolates: true);
|
||||
await Bootstrap.initDomain(isar, drift, logDb, shouldBufferLogs: false);
|
||||
final ref = ProviderContainer(
|
||||
overrides: [
|
||||
|
||||
@@ -297,7 +297,9 @@ class _SyncStatusIndicatorState extends ConsumerState<_SyncStatusIndicator> with
|
||||
Widget build(BuildContext context) {
|
||||
final syncStatus = ref.watch(syncStatusProvider);
|
||||
final isSyncing = syncStatus.isRemoteSyncing || syncStatus.isLocalSyncing;
|
||||
|
||||
print(
|
||||
"SyncStatusIndicator build - syncStatus.isRemoteSyncing: ${syncStatus.isRemoteSyncing} , isLocalSyncing: ${syncStatus.isLocalSyncing}, isHashing: ${syncStatus.isHashing}",
|
||||
);
|
||||
// Control animations based on sync status
|
||||
if (isSyncing) {
|
||||
if (!_rotationController.isAnimating) {
|
||||
|
||||
@@ -27,7 +27,7 @@ void main() {
|
||||
for (final toVersion in versions.skip(i + 1)) {
|
||||
test('to $toVersion', () async {
|
||||
final schema = await verifier.schemaAt(fromVersion);
|
||||
final db = Drift(schema.newConnection());
|
||||
final db = Drift(executor: schema.newConnection());
|
||||
await verifier.migrateAndValidate(db, toVersion);
|
||||
await db.close();
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ void main() {
|
||||
late MediumFactory mediumFactory;
|
||||
|
||||
setUp(() {
|
||||
db = Drift(DatabaseConnection(NativeDatabase.memory(), closeStreamsSynchronously: true));
|
||||
db = Drift(executor: DatabaseConnection(NativeDatabase.memory(), closeStreamsSynchronously: true));
|
||||
mediumFactory = MediumFactory(db);
|
||||
});
|
||||
|
||||
|
||||
@@ -62,7 +62,10 @@ void main() {
|
||||
);
|
||||
|
||||
setUpAll(() async {
|
||||
final loggerDb = DriftLogger(DatabaseConnection(NativeDatabase.memory(), closeStreamsSynchronously: true));
|
||||
final loggerDb = DriftLogger(
|
||||
executor: DatabaseConnection(NativeDatabase.memory(), closeStreamsSynchronously: true),
|
||||
shareAcrossIsolates: true,
|
||||
);
|
||||
final LogRepository logRepository = LogRepository(loggerDb);
|
||||
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
Reference in New Issue
Block a user