mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-15 18:02:58 +08:00
fix: marketplace retry not working
This commit is contained in:
@@ -125,7 +125,7 @@ class MarketplacePanel : JPanel(BorderLayout()), Disposable {
|
||||
cardLayout.show(cardPanel, PanelState.FetchFailed.name)
|
||||
}
|
||||
} finally {
|
||||
isLoading.set(true)
|
||||
isLoading.set(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.slf4j.LoggerFactory
|
||||
import org.xml.sax.InputSource
|
||||
import java.io.StringReader
|
||||
import java.util.*
|
||||
import java.util.concurrent.Callable
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
@@ -97,11 +98,14 @@ internal class MarketplaceManager private constructor() {
|
||||
|
||||
val plugins = mutableListOf<MarketplacePlugin>()
|
||||
val executorService = Executors.newVirtualThreadPerTaskExecutor()
|
||||
val futures = repositories
|
||||
.map { url -> executorService.submit<List<MarketplacePlugin>> { getPlugins(url, version) } }
|
||||
val futures = executorService
|
||||
.invokeAll(repositories.map { Callable { getPlugins(it, version) } }, 30, TimeUnit.SECONDS)
|
||||
|
||||
for (future in futures) {
|
||||
try {
|
||||
plugins.addAll(future.get(1, TimeUnit.MINUTES))
|
||||
if (future.isDone) {
|
||||
plugins.addAll(future.get())
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
if (log.isWarnEnabled) {
|
||||
log.warn(e.message, e)
|
||||
@@ -110,6 +114,8 @@ internal class MarketplaceManager private constructor() {
|
||||
}
|
||||
}
|
||||
|
||||
executorService.shutdown()
|
||||
|
||||
if (plugins.isEmpty()) {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user