Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Download the next books in the queue even if an earlier download of them was deleted by hand

Barnabas93b2ee7eb4d8
diff --git a/lib/providers/_lp_core.dart b/lib/providers/_lp_core.dart
index 3b9cf9af..e0d2a2c4 100644
--- a/lib/providers/_lp_core.dart
+++ b/lib/providers/_lp_core.dart
@@ -3743,6 +3743,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
if (downloads.isDownloaded(key) || downloads.isDownloading(key)) {
continue;
}
+ await downloads.liftAutoDownloadBlock(key);
final error = await downloads.downloadItem(
api: api,
itemId: key,
diff --git a/lib/services/download_service.dart b/lib/services/download_service.dart
index b35ffcfd..676c67b9 100644
--- a/lib/services/download_service.dart
+++ b/lib/services/download_service.dart
@@ -509,6 +509,14 @@ class DownloadService extends ChangeNotifier {
/// before they call, or they announce work that never happens.
bool isAutoDownloadBlocked(String itemId) =>
_autoDownloadBlocked.contains(itemId);
+
+ /// The queue's next-up books are wanted whatever happened to an earlier
+ /// download of them, so the planner lifts the block before it downloads.
+ Future<void> liftAutoDownloadBlock(String itemId) async {
+ if (!_autoDownloadBlocked.remove(itemId)) return;
+ debugPrint('[Download] $itemId is next in the queue - auto-download may fetch it again');
+ await _saveAutoDownloadBlocks();
+ }
static const _autoDownloadBlockedKey = 'auto_download_blocked';
/// The current Android SAF folder URI (content://), or null if using default.