fun download()

in backend/src/main/kotlin/org/jetbrains/downloadThis/Download.kt [115:129]


fun download(query: String, destinationDir: File, statusListener: (DownloadStatus) -> Unit) {
    if (!destinationDir.isDirectory) {
        statusListener(Failed("${destinationDir.absolutePath} is not a directory", query, destinationDir))
        return
    }

    when {
        isLocalTorrentFile(query) -> downloadTorrent(File(query), destinationDir, statusListener)
        isMagnetLink(query) -> statusListener(Failed("Magnet links are not supported now", query, destinationDir))
        isTorrentHash(query) -> statusListener(Failed("Torrent hashes are not supported now", query, destinationDir))
        isCurlQuery(query) -> statusListener(Failed("Curl queries are not supported now", query, destinationDir))
        isHttpLink(query) -> downloadHttpLink(query, destinationDir, statusListener)
        else -> statusListener(Failed("Can't understand link type", query, destinationDir))
    }
}