mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
fix: prevent isolate deadlock (#21692)
This commit is contained in:
parent
059a0e8aa8
commit
59accbf32a
2 changed files with 11 additions and 6 deletions
|
|
@ -169,15 +169,20 @@ class BackgroundWorkerBgService extends BackgroundWorkerFlutterApi {
|
||||||
try {
|
try {
|
||||||
_isCleanedUp = true;
|
_isCleanedUp = true;
|
||||||
_logger.info("Cleaning up background worker");
|
_logger.info("Cleaning up background worker");
|
||||||
await _ref.read(backgroundSyncProvider).cancel();
|
final cleanupFutures = [
|
||||||
await _ref.read(backgroundSyncProvider).cancelLocal();
|
_drift.close(),
|
||||||
|
_driftLogger.close(),
|
||||||
|
_ref.read(backgroundSyncProvider).cancel(),
|
||||||
|
_ref.read(backgroundSyncProvider).cancelLocal(),
|
||||||
|
];
|
||||||
|
|
||||||
if (_isar.isOpen) {
|
if (_isar.isOpen) {
|
||||||
await _isar.close();
|
cleanupFutures.add(_isar.close());
|
||||||
}
|
}
|
||||||
await _drift.close();
|
|
||||||
await _driftLogger.close();
|
|
||||||
_ref.dispose();
|
_ref.dispose();
|
||||||
_lockManager.releaseLock();
|
_lockManager.releaseLock();
|
||||||
|
|
||||||
|
await Future.wait(cleanupFutures);
|
||||||
_logger.info("Background worker resources cleaned up");
|
_logger.info("Background worker resources cleaned up");
|
||||||
} catch (error, stack) {
|
} catch (error, stack) {
|
||||||
debugPrint('Failed to cleanup background worker: $error with stack: $stack');
|
debugPrint('Failed to cleanup background worker: $error with stack: $stack');
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ class Drift extends $Drift implements IDatabaseRepository {
|
||||||
await customStatement('PRAGMA foreign_keys = ON');
|
await customStatement('PRAGMA foreign_keys = ON');
|
||||||
await customStatement('PRAGMA synchronous = NORMAL');
|
await customStatement('PRAGMA synchronous = NORMAL');
|
||||||
await customStatement('PRAGMA journal_mode = WAL');
|
await customStatement('PRAGMA journal_mode = WAL');
|
||||||
await customStatement('PRAGMA busy_timeout = 500');
|
await customStatement('PRAGMA busy_timeout = 30000');
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue