mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-04-29 22:27:31 +00:00
fix: 修复Maven 本地仓库文件夹未初始化的问题.
当本地仓库文件夹未初始化时, 将导致文件写入失败, 已修复该问题.
This commit is contained in:
parent
3e51327ed7
commit
d14ef9de36
@ -9,6 +9,7 @@ import org.telegram.telegrambots.bots.DefaultBotOptions
|
|||||||
import org.telegram.telegrambots.meta.TelegramBotsApi
|
import org.telegram.telegrambots.meta.TelegramBotsApi
|
||||||
import org.telegram.telegrambots.meta.generics.BotSession
|
import org.telegram.telegrambots.meta.generics.BotSession
|
||||||
import org.telegram.telegrambots.updatesreceivers.DefaultBotSession
|
import org.telegram.telegrambots.updatesreceivers.DefaultBotSession
|
||||||
|
import java.io.File
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
private val log = KotlinLogging.logger { }
|
private val log = KotlinLogging.logger { }
|
||||||
@ -54,16 +55,24 @@ internal class Launcher : AutoCloseable {
|
|||||||
|
|
||||||
private val botApi = TelegramBotsApi(DefaultBotSession::class.java)
|
private val botApi = TelegramBotsApi(DefaultBotSession::class.java)
|
||||||
private val botSessionMap = mutableMapOf<ScalaBot, BotSession>()
|
private val botSessionMap = mutableMapOf<ScalaBot, BotSession>()
|
||||||
private val mavenLocalRepository =
|
private val mavenLocalRepository = getMavenLocalRepository()
|
||||||
if (Const.config.mavenLocalRepository != null && Const.config.mavenLocalRepository.isNotEmpty()) {
|
|
||||||
val repoPath = AppPaths.DATA_ROOT.file.toPath()
|
private fun getMavenLocalRepository(): LocalRepository {
|
||||||
.resolve(Const.config.mavenLocalRepository)
|
val localPath =
|
||||||
.toRealPath()
|
if (Const.config.mavenLocalRepository != null && Const.config.mavenLocalRepository.isNotEmpty()) {
|
||||||
.toFile()
|
val repoPath = AppPaths.DATA_ROOT.file.toPath()
|
||||||
LocalRepository(repoPath)
|
.resolve(Const.config.mavenLocalRepository)
|
||||||
} else {
|
.toRealPath()
|
||||||
LocalRepository("${System.getProperty("user.home")}/.m2/repository")
|
.toFile()
|
||||||
|
repoPath
|
||||||
|
} else {
|
||||||
|
File("${System.getProperty("user.home")}/.m2/repository")
|
||||||
|
}
|
||||||
|
if (!localPath.exists()) {
|
||||||
|
localPath.mkdirs()
|
||||||
}
|
}
|
||||||
|
return LocalRepository(localPath)
|
||||||
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun launch(): Boolean {
|
fun launch(): Boolean {
|
||||||
|
Loading…
Reference in New Issue
Block a user