mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
chore: log reason for foreground backup cancellation (#30570)
Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
parent
b2eb62dfa5
commit
1a40ef66b4
6 changed files with 9 additions and 7 deletions
|
|
@ -143,7 +143,7 @@ class _DriftBackupPageState extends ConsumerState<DriftBackupPage> {
|
|||
onStart: () async => await startBackup(),
|
||||
onStop: () {
|
||||
syncSuccess = null;
|
||||
backupNotifier.stopForegroundBackup();
|
||||
backupNotifier.stopForegroundBackup(reason: "backup button toggled off");
|
||||
},
|
||||
),
|
||||
switch (error) {
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ class _DriftBackupAlbumSelectionPageState extends ConsumerState<DriftBackupAlbum
|
|||
// Waits for hashing to be cancelled before starting a new one
|
||||
unawaited(nativeSync.cancelHashing().whenComplete(() => backgroundSync.hashAssets()));
|
||||
if (isBackupEnabled) {
|
||||
backupNotifier.stopForegroundBackup();
|
||||
backupNotifier.stopForegroundBackup(reason: "backup albums updated");
|
||||
unawaited(
|
||||
backgroundSync.syncRemote().then((success) {
|
||||
if (success) {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class DriftBackupOptionsPage extends ConsumerWidget {
|
|||
|
||||
final backupNotifier = ref.read(driftBackupProvider.notifier);
|
||||
final backgroundSync = ref.read(backgroundSyncProvider);
|
||||
backupNotifier.stopForegroundBackup();
|
||||
backupNotifier.stopForegroundBackup(reason: "backup settings updated");
|
||||
unawaited(
|
||||
backgroundSync.syncRemote().then((success) {
|
||||
if (success) {
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ class AppLifeCycleNotifier extends StateNotifier<AppLifeCycleEnum> {
|
|||
|
||||
Future<void> _performPause() {
|
||||
if (_ref.read(authProvider).isAuthenticated) {
|
||||
_ref.read(driftBackupProvider.notifier).stopForegroundBackup();
|
||||
_ref.read(driftBackupProvider.notifier).stopForegroundBackup(reason: "the app being sent to the background");
|
||||
|
||||
_ref.read(websocketProvider.notifier).disconnect();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ class DriftBackupNotifier extends StateNotifier<DriftBackupState> {
|
|||
Future<void> startForegroundBackup(String userId) async {
|
||||
// Cancel any existing backup before starting a new one
|
||||
if (_cancelToken != null) {
|
||||
stopForegroundBackup();
|
||||
stopForegroundBackup(reason: "restarting the backup");
|
||||
}
|
||||
|
||||
state = state.copyWith(error: BackupError.none);
|
||||
|
|
@ -283,7 +283,10 @@ class DriftBackupNotifier extends StateNotifier<DriftBackupState> {
|
|||
);
|
||||
}
|
||||
|
||||
void stopForegroundBackup() {
|
||||
void stopForegroundBackup({required String reason}) {
|
||||
if (_cancelToken != null) {
|
||||
_logger.info("Foreground backup cancelled: $reason");
|
||||
}
|
||||
_cancelToken?.complete();
|
||||
_cancelToken = null;
|
||||
_uploadSpeedManager.clear();
|
||||
|
|
|
|||
|
|
@ -384,7 +384,6 @@ class ForegroundUploadService {
|
|||
if (result.isSuccess && result.remoteAssetId != null) {
|
||||
callbacks.onSuccess?.call(asset.localId!, result.remoteAssetId!);
|
||||
} else if (result.isCancelled) {
|
||||
_logger.warning(() => "Backup was cancelled by the user");
|
||||
shouldAbortUpload = true;
|
||||
} else if (result.errorMessage != null) {
|
||||
_logger.severe(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue