fix cleaning up of hopeless downloads in gui

This commit is contained in:
Zlatin Balevsky
2020-09-23 15:21:47 +01:00
parent e9db22c562
commit c11a427483
2 changed files with 13 additions and 14 deletions

View File

@ -222,17 +222,13 @@ class MainFrameController {
@ControllerAction
void clear() {
def toRemove = []
model.downloads.each {
if (it.downloader.getCurrentState() == Downloader.DownloadState.CANCELLED) {
toRemove << it
} else if (it.downloader.getCurrentState() == Downloader.DownloadState.FINISHED) {
toRemove << it
}
}
toRemove.each {
model.downloads.remove(it)
}
model.downloads.removeAll {
def state = it.downloader.getCurrentState()
state == Downloader.DownloadState.CANCELLED ||
state == Downloader.DownloadState.FINISHED ||
state == Downloader.DownloadState.HOPELESS
}
model.clearButtonEnabled = false
}

View File

@ -177,22 +177,25 @@ class MainFrameModel {
if (!mvcGroup.alive)
return
// remove cancelled or finished downloads
// remove cancelled or finished or hopeless downloads
if (!clearButtonEnabled || uiSettings.clearCancelledDownloads || uiSettings.clearFinishedDownloads) {
def toRemove = []
downloads.each {
if (it.downloader.getCurrentState() == Downloader.DownloadState.CANCELLED) {
def state = it.downloader.getCurrentState()
if (state == Downloader.DownloadState.CANCELLED) {
if (uiSettings.clearCancelledDownloads) {
toRemove << it
} else {
clearButtonEnabled = true
}
} else if (it.downloader.getCurrentState() == Downloader.DownloadState.FINISHED) {
} else if (state == Downloader.DownloadState.FINISHED) {
if (uiSettings.clearFinishedDownloads) {
toRemove << it
} else {
clearButtonEnabled = true
}
} else if (state == Downloader.DownloadState.HOPELESS) {
clearButtonEnabled = true
}
}
toRemove.each {