mirror of
https://github.com/immich-app/immich
synced 2026-08-29 13:15:45 +00:00
Merge branch 'main' into fix/failed-sync-blocks-resume
This commit is contained in:
commit
c35a51b511
2 changed files with 11 additions and 9 deletions
|
|
@ -93,13 +93,13 @@ class AppLifeCycleNotifier extends StateNotifier<AppLifeCycleEnum> {
|
|||
await _ref.read(galleryPermissionNotifier.notifier).getGalleryPermissionStatus();
|
||||
}
|
||||
|
||||
Future<void> _safeRun(Future<void> action, String debugName) async {
|
||||
Future<void> _safeRun(Future<void> Function() action, String debugName) async {
|
||||
if (!_shouldContinueOperation()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await action;
|
||||
await action();
|
||||
} catch (e, stackTrace) {
|
||||
_log.warning("Error during $debugName operation", e, stackTrace);
|
||||
}
|
||||
|
|
@ -123,13 +123,15 @@ class AppLifeCycleNotifier extends StateNotifier<AppLifeCycleEnum> {
|
|||
try {
|
||||
bool syncSuccess = false;
|
||||
await Future.wait([
|
||||
_safeRun(backgroundManager.syncLocal(full: CurrentPlatform.isAndroid ? true : false), "syncLocal"),
|
||||
_safeRun(backgroundManager.syncRemote().then((success) => syncSuccess = success), "syncRemote"),
|
||||
_safeRun(() => backgroundManager.syncLocal(full: CurrentPlatform.isAndroid), "syncLocal"),
|
||||
_safeRun(() async {
|
||||
syncSuccess = await backgroundManager.syncRemote();
|
||||
}, "syncRemote"),
|
||||
]);
|
||||
_ref.invalidate(driftMemoryFutureProvider);
|
||||
if (syncSuccess) {
|
||||
await Future.wait([
|
||||
_safeRun(backgroundManager.hashAssets(), "hashAssets").then((_) {
|
||||
_safeRun(backgroundManager.hashAssets, "hashAssets").then((_) {
|
||||
unawaited(_resumeBackup());
|
||||
}),
|
||||
_resumeBackup(),
|
||||
|
|
@ -137,11 +139,11 @@ class AppLifeCycleNotifier extends StateNotifier<AppLifeCycleEnum> {
|
|||
// _safeRun(backgroundManager.syncCloudIds(), "syncCloudIds"),
|
||||
]);
|
||||
} else {
|
||||
await _safeRun(backgroundManager.hashAssets(), "hashAssets");
|
||||
await _safeRun(backgroundManager.hashAssets, "hashAssets");
|
||||
}
|
||||
|
||||
if (isAlbumLinkedSyncEnable) {
|
||||
await _safeRun(backgroundManager.syncLinkedAlbum(), "syncLinkedAlbum");
|
||||
await _safeRun(backgroundManager.syncLinkedAlbum, "syncLinkedAlbum");
|
||||
}
|
||||
} catch (e, stackTrace) {
|
||||
_log.severe("Error during background sync", e, stackTrace);
|
||||
|
|
@ -155,7 +157,7 @@ class AppLifeCycleNotifier extends StateNotifier<AppLifeCycleEnum> {
|
|||
final currentUser = Store.tryGet(StoreKey.currentUser);
|
||||
if (currentUser != null) {
|
||||
await _safeRun(
|
||||
_ref.read(driftBackupProvider.notifier).startForegroundBackup(currentUser.id),
|
||||
() => _ref.read(driftBackupProvider.notifier).startForegroundBackup(currentUser.id),
|
||||
"handleBackupResume",
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ void main() {
|
|||
firstRun('asset-1', 'remote-1');
|
||||
expect(notifier.state.remainderCount, 0);
|
||||
|
||||
notifier.stopForegroundBackup();
|
||||
notifier.stopForegroundBackup(reason: "test");
|
||||
|
||||
final resumedRun = await startAndCaptureOnSuccess();
|
||||
expect(notifier.state.remainderCount, 1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue