fix: harden release builds and queue scheduling

This commit is contained in:
nimbold
2026-06-03 04:15:53 +03:30
parent 8c2dee2c13
commit 0c5e031f49
5 changed files with 132 additions and 28 deletions
+11 -15
View File
@@ -131,15 +131,17 @@ final class SchedulerController: ObservableObject {
}
private func triggerQueues() {
guard !settings.targetQueueIDs.isEmpty else { return }
let runnableQueueIDs = settings.targetQueueIDs.filter { queueID in
downloadController.queues.contains(where: { $0.id == queueID }) &&
downloadController.queueItems(for: queueID).contains(where: { $0.status == .queued })
}
guard !runnableQueueIDs.isEmpty else { return }
isRunning = true
for queueID in settings.targetQueueIDs {
// Check if queue still exists
if downloadController.queues.contains(where: { $0.id == queueID }) {
downloadController.startQueue(queueID: queueID)
}
for queueID in runnableQueueIDs {
downloadController.startQueue(queueID: queueID)
}
checkIfRunningFinished()
@@ -148,15 +150,9 @@ final class SchedulerController: ObservableObject {
private func checkIfRunningFinished() {
guard isRunning else { return }
// A queue is finished if there are no items in .queued or .downloading state for that queue.
// Wait, what if the queue is empty? We don't trigger anything.
var hasActiveItems = false
for item in downloadController.downloads {
if let qid = item.queueID, settings.targetQueueIDs.contains(qid) {
if item.status == .queued || item.status == .downloading {
hasActiveItems = true
break
}
let hasActiveItems = settings.targetQueueIDs.contains { queueID in
downloadController.queueItems(for: queueID).contains {
$0.status == .queued || $0.status == .downloading
}
}