forked from Cutlery/immich
fix: persist WiFi + charging settings of background backup (#553)
This commit is contained in:
parent
25e68cf826
commit
5172242f88
@ -22,4 +22,6 @@ const String userSettingInfoBox = "immichUserSettingInfoBox";
|
|||||||
|
|
||||||
// Background backup Info
|
// Background backup Info
|
||||||
const String backgroundBackupInfoBox = "immichBackgroundBackupInfoBox"; // Box
|
const String backgroundBackupInfoBox = "immichBackgroundBackupInfoBox"; // Box
|
||||||
const String backupFailedSince = "immichBackupFailedSince"; // Key 1
|
const String backupFailedSince = "immichBackupFailedSince"; // Key 1
|
||||||
|
const String backupRequireWifi = "immichBackupRequireWifi"; // Key 2
|
||||||
|
const String backupRequireCharging = "immichBackupRequireCharging"; // Key 3
|
||||||
|
@ -138,7 +138,12 @@ class BackupNotifier extends StateNotifier<BackUpState> {
|
|||||||
requireUnmetered: state.backupRequireWifi,
|
requireUnmetered: state.backupRequireWifi,
|
||||||
requireCharging: state.backupRequireCharging,
|
requireCharging: state.backupRequireCharging,
|
||||||
);
|
);
|
||||||
if (!success) {
|
if (success) {
|
||||||
|
await Hive.box(backgroundBackupInfoBox)
|
||||||
|
.put(backupRequireWifi, state.backupRequireWifi);
|
||||||
|
await Hive.box(backgroundBackupInfoBox)
|
||||||
|
.put(backupRequireCharging, state.backupRequireCharging);
|
||||||
|
} else {
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
backgroundBackup: wasEnabled,
|
backgroundBackup: wasEnabled,
|
||||||
backupRequireWifi: wasWifi,
|
backupRequireWifi: wasWifi,
|
||||||
@ -549,10 +554,13 @@ class BackupNotifier extends StateNotifier<BackUpState> {
|
|||||||
albums.lastExcludedBackupTime,
|
albums.lastExcludedBackupTime,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
final Box backgroundBox = await Hive.openBox(backgroundBackupInfoBox);
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
backupProgress: previous,
|
backupProgress: previous,
|
||||||
selectedBackupAlbums: selectedAlbums,
|
selectedBackupAlbums: selectedAlbums,
|
||||||
excludedBackupAlbums: excludedAlbums,
|
excludedBackupAlbums: excludedAlbums,
|
||||||
|
backupRequireWifi: backgroundBox.get(backupRequireWifi),
|
||||||
|
backupRequireCharging: backgroundBox.get(backupRequireCharging),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return _resumeBackup();
|
return _resumeBackup();
|
||||||
@ -590,6 +598,13 @@ class BackupNotifier extends StateNotifier<BackUpState> {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
debugPrint("[_notifyBackgroundServiceCanRun] failed to close box");
|
debugPrint("[_notifyBackgroundServiceCanRun] failed to close box");
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
if (Hive.isBoxOpen(backgroundBackupInfoBox)) {
|
||||||
|
await Hive.box(backgroundBackupInfoBox).close();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
debugPrint("[_notifyBackgroundServiceCanRun] failed to close box");
|
||||||
|
}
|
||||||
_backgroundService.releaseLock();
|
_backgroundService.releaseLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user