fix cleaning up of hopeless downloads in gui
This commit is contained in:
@ -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
|
||||
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user