diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPicturesService.java b/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPicturesService.java index f4aadb4917d..2d08ebe8621 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPicturesService.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPicturesService.java @@ -78,7 +78,7 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements private List cardsAll; private List cardsMissing; - private final List cardsDownloadQueue; + private List cardsDownloadQueue; private final List selectedSets = new ArrayList<>(); private CardImageSource selectedSource; @@ -975,9 +975,16 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements }); // remove all downloaded cards, missing must be remains - // TODO: too slow on finished, must be reworked (e.g. run full check instead remove) - this.cardsDownloadQueue.removeAll(downloadedCards); - this.cardsMissing.removeAll(downloadedCards); + // workaround for fast remove + Set finished = new HashSet<>(downloadedCards); + this.cardsDownloadQueue = Collections.synchronizedList(this.cardsDownloadQueue.stream() + .filter(c -> !finished.contains(c)) + .collect(Collectors.toList()) + ); + this.cardsMissing = Collections.synchronizedList(this.cardsMissing.stream() + .filter(c -> !finished.contains(c)) + .collect(Collectors.toList()) + ); if (this.cardsDownloadQueue.isEmpty()) { // stop download