in src/main/kotlin/org/jetbrains/tinygoplugin/sdk/TinyGoDownloadSdkService.kt [97:132]
override fun run(indicator: ProgressIndicator) {
try {
logger.debug("Started downloading TinyGo SDK")
indicator.isIndeterminate = false
val extension = if (GoOsManager.isWindows()) ".zip" else ".tar.gz"
var arch = GoUtil.systemArch()
val fileName = LazyString { "tinygo${sdk.version}.${GoUtil.systemOS()}-$arch$extension" }
val url = LazyString {
"https://github.com/$TINYGO_GITHUB/releases/download/v${sdk.version}/$fileName"
}
@Suppress("SwallowedException")
try {
HttpRequests.request(url.toString()).tryConnect()
} catch (e: IOException) {
arch = osManager.emulatedArch(arch)
}
val downloadedArchive = Files.createTempFile("for-actual-downloading-", extension)
DownloadUtil.downloadContentToFile(
indicator,
url.toString(),
downloadedArchive.toFile()
)
logger.debug("Downloaded TinyGo SDK into temp")
indicator.text2 = ""
// checksum verifying??
unpackSdk(indicator, downloadedArchive, VfsUtilCore.urlToPath(sdk.homeUrl))
synchronized(lock) {
success = true
logger.debug("TinyGo SDK download and unpacking succeeded")
}
} catch (e: IOException) {
error("Unable to download TinyGo SDK from GitHub", e, null, onFinish)
logger.error(e.message)
}
}