mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
chore: robust isolation tasks coordination (#21605)
* chore: robust isolation tasks coordination * give more time for database transaction to clean up * chore: clean up logs * chore: clean up logs * fix: logs
This commit is contained in:
parent
3a29522df6
commit
88c0243a20
3 changed files with 198 additions and 67 deletions
|
|
@ -24,6 +24,7 @@ class BackgroundSyncManager {
|
|||
Cancelable<void>? _syncTask;
|
||||
Cancelable<void>? _syncWebsocketTask;
|
||||
Cancelable<void>? _deviceAlbumSyncTask;
|
||||
Cancelable<void>? _linkedAlbumSyncTask;
|
||||
Cancelable<void>? _hashTask;
|
||||
|
||||
BackgroundSyncManager({
|
||||
|
|
@ -53,6 +54,12 @@ class BackgroundSyncManager {
|
|||
_syncWebsocketTask?.cancel();
|
||||
_syncWebsocketTask = null;
|
||||
|
||||
if (_linkedAlbumSyncTask != null) {
|
||||
futures.add(_linkedAlbumSyncTask!.future);
|
||||
}
|
||||
_linkedAlbumSyncTask?.cancel();
|
||||
_linkedAlbumSyncTask = null;
|
||||
|
||||
try {
|
||||
await Future.wait(futures);
|
||||
} on CanceledError {
|
||||
|
|
@ -158,8 +165,14 @@ class BackgroundSyncManager {
|
|||
}
|
||||
|
||||
Future<void> syncLinkedAlbum() {
|
||||
final task = runInIsolateGentle(computation: syncLinkedAlbumsIsolated);
|
||||
return task.future;
|
||||
if (_linkedAlbumSyncTask != null) {
|
||||
return _linkedAlbumSyncTask!.future;
|
||||
}
|
||||
|
||||
_linkedAlbumSyncTask = runInIsolateGentle(computation: syncLinkedAlbumsIsolated);
|
||||
return _linkedAlbumSyncTask!.whenComplete(() {
|
||||
_linkedAlbumSyncTask = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue