feat(library): pause and resume library scans

The scan progress tile offers Pause and Resume. A paused scan releases its foreground service and wake lock, shows a paused notice, and resumes from the next unscanned file.
This commit is contained in:
zarzet committed 2026-10-01 21:00:42 +07:00
1 parent fe36f08918
commit 50f21d9c82
7 files changed
+356 -18

No files matched your search

+19
View File
@@ -539,6 +539,25 @@ class NotificationService {
);
}
Future<void> showLibraryScanPaused({required int scannedFiles}) async {
if (!_isInitialized) await initialize();
await _showSafely(
id: libraryScanId,
title: _l10n?.notifLibraryScanPaused ?? 'Library scan paused',
body:
_l10n?.notifLibraryScanPausedBody(scannedFiles) ??
'$scannedFiles files scanned. Resume in Local Library settings to '
'continue from here.',
details: _details(library: true),
);
}
/// Clears a paused-scan notice once the foreground service shows progress.
Future<void> cancelLibraryScanNotification() async {
await _notifications.cancel(id: libraryScanId);
}
Future<void> showUpdateDownloadProgress({
required String version,
required int received,
+9
View File
@@ -2346,6 +2346,15 @@ class PlatformBridge {
await _channel.invokeMethod('cancelLibraryScan');
}
/// Holds the running native scan at its next file; it keeps its position.
static Future<void> pauseLibraryScan() async {
await _channel.invokeMethod('pauseLibraryScan');
}
static Future<void> resumeLibraryScan() async {
await _channel.invokeMethod('resumeLibraryScan');
}
static Object? _decodeJsonResult(dynamic result) {
if (result is String) {
if (result.isEmpty) return null;