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.generics.BotSession
|
||||
import org.telegram.telegrambots.updatesreceivers.DefaultBotSession
|
||||
import java.io.File
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
private val log = KotlinLogging.logger { }
|
||||
@ -54,15 +55,23 @@ internal class Launcher : AutoCloseable {
|
||||
|
||||
private val botApi = TelegramBotsApi(DefaultBotSession::class.java)
|
||||
private val botSessionMap = mutableMapOf<ScalaBot, BotSession>()
|
||||
private val mavenLocalRepository =
|
||||
private val mavenLocalRepository = getMavenLocalRepository()
|
||||
|
||||
private fun getMavenLocalRepository(): LocalRepository {
|
||||
val localPath =
|
||||
if (Const.config.mavenLocalRepository != null && Const.config.mavenLocalRepository.isNotEmpty()) {
|
||||
val repoPath = AppPaths.DATA_ROOT.file.toPath()
|
||||
.resolve(Const.config.mavenLocalRepository)
|
||||
.toRealPath()
|
||||
.toFile()
|
||||
LocalRepository(repoPath)
|
||||
repoPath
|
||||
} else {
|
||||
LocalRepository("${System.getProperty("user.home")}/.m2/repository")
|
||||
File("${System.getProperty("user.home")}/.m2/repository")
|
||||
}
|
||||
if (!localPath.exists()) {
|
||||
localPath.mkdirs()
|
||||
}
|
||||
return LocalRepository(localPath)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
|
Loading…
Reference in New Issue
Block a user