mirror of
https://github.com/samsonjs/immich.git
synced 2026-04-27 15:07:45 +00:00
fix: upload progress bar flickering (#25829)
* fix: upload progress bar flickering * pr feedback and more logs
This commit is contained in:
parent
25f2273e24
commit
23445fdcc1
3 changed files with 17 additions and 8 deletions
|
|
@ -259,6 +259,11 @@ class DriftBackupNotifier extends StateNotifier<DriftBackupState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> startForegroundBackup(String userId) async {
|
Future<void> startForegroundBackup(String userId) async {
|
||||||
|
// Cancel any existing backup before starting a new one
|
||||||
|
if (state.cancelToken != null) {
|
||||||
|
await stopForegroundBackup();
|
||||||
|
}
|
||||||
|
|
||||||
state = state.copyWith(error: BackupError.none);
|
state = state.copyWith(error: BackupError.none);
|
||||||
|
|
||||||
final cancelToken = CancellationToken();
|
final cancelToken = CancellationToken();
|
||||||
|
|
@ -375,21 +380,21 @@ class DriftBackupNotifier extends StateNotifier<DriftBackupState> {
|
||||||
_logger.warning("Skip handleBackupResume (pre-call): notifier disposed");
|
_logger.warning("Skip handleBackupResume (pre-call): notifier disposed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.info("Resuming backup tasks...");
|
_logger.info("Start background backup sequence");
|
||||||
state = state.copyWith(error: BackupError.none);
|
state = state.copyWith(error: BackupError.none);
|
||||||
final tasks = await _backgroundUploadService.getActiveTasks(kBackupGroup);
|
final tasks = await _backgroundUploadService.getActiveTasks(kBackupGroup);
|
||||||
if (!mounted) {
|
if (!mounted) {
|
||||||
_logger.warning("Skip handleBackupResume (post-call): notifier disposed");
|
_logger.warning("Skip handleBackupResume (post-call): notifier disposed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.info("Found ${tasks.length} tasks");
|
_logger.info("Found ${tasks.length} pending tasks");
|
||||||
|
|
||||||
if (tasks.isEmpty) {
|
if (tasks.isEmpty) {
|
||||||
_logger.info("Start backup with URLSession");
|
_logger.info("No pending tasks, starting new upload");
|
||||||
return _backgroundUploadService.uploadBackupCandidates(userId);
|
return _backgroundUploadService.uploadBackupCandidates(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.info("Tasks to resume: ${tasks.length}");
|
_logger.info("Resuming upload ${tasks.length} assets");
|
||||||
return _backgroundUploadService.resume();
|
return _backgroundUploadService.resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -164,9 +164,12 @@ class BackgroundUploadService {
|
||||||
|
|
||||||
final candidates = await _backupRepository.getCandidates(userId);
|
final candidates = await _backupRepository.getCandidates(userId);
|
||||||
if (candidates.isEmpty) {
|
if (candidates.isEmpty) {
|
||||||
|
_logger.info("No new backup candidates found, finishing background upload");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_logger.info("Found ${candidates.length} backup candidates for background tasks");
|
||||||
|
|
||||||
const batchSize = 100;
|
const batchSize = 100;
|
||||||
final batch = candidates.take(batchSize).toList();
|
final batch = candidates.take(batchSize).toList();
|
||||||
List<UploadTask> tasks = [];
|
List<UploadTask> tasks = [];
|
||||||
|
|
@ -179,6 +182,7 @@ class BackgroundUploadService {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tasks.isNotEmpty && !shouldAbortQueuingTasks) {
|
if (tasks.isNotEmpty && !shouldAbortQueuingTasks) {
|
||||||
|
_logger.info("Enqueuing ${tasks.length} background upload tasks");
|
||||||
await enqueueTasks(tasks);
|
await enqueueTasks(tasks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1249,10 +1249,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
|
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.16.0"
|
version: "1.17.0"
|
||||||
mime:
|
mime:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -1942,10 +1942,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
|
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.6"
|
version: "0.7.7"
|
||||||
thumbhash:
|
thumbhash:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue