fun setup()

in plugin/src/main/kotlin/org/jetbrains/qodana/Qodana.kt [78:103]


    fun setup(
        path: File,
        version: String = getLatestVersion(),
    ): String {
        val downloadURL = getQodanaUrl(version = version)
        val useNightly = version == "nightly"

        if (path.exists()) {
            try {
                if (!useNightly) verifyChecksum(path, getChecksum(version))
                return path.absolutePath
            } catch (e: IOException) {
                log.warning("Checksum verification failed. Redownloading the binary.")
            }
            path.delete()
        }

        try {
            download(downloadURL, path)
            if (!useNightly) verifyChecksum(path, getChecksum(version))
        } catch (e: IOException) {
            throw IOException("Unable to download latest qodana binary", e)
        }

        return path.absolutePath
    }