only allow one download per infohash from gui

This commit is contained in:
Zlatin Balevsky
2019-06-17 11:25:21 +01:00
parent 0db7077a45
commit 546eb4e9d3
4 changed files with 35 additions and 18 deletions

View File

@@ -60,11 +60,14 @@ class MainFrameModel {
@Observable int connections
@Observable String me
@Observable boolean searchButtonsEnabled
@Observable boolean downloadActionEnabled
@Observable boolean trustButtonsEnabled
@Observable boolean cancelButtonEnabled
@Observable boolean retryButtonEnabled
private final Set<InfoHash> infoHashes = new HashSet<>()
private final Set<InfoHash> downloadInfoHashes = new HashSet<>()
volatile Core core
@@ -171,6 +174,7 @@ class MainFrameModel {
void onDownloadStartedEvent(DownloadStartedEvent e) {
runInsideUIAsync {
downloads << e
downloadInfoHashes.add(e.downloader.infoHash)
}
}
@@ -340,4 +344,8 @@ class MainFrameModel {
return destination == other.destination
}
}
boolean canDownload(InfoHash hash) {
!downloadInfoHashes.contains(hash)
}
}