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