mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-04-29 22:27:31 +00:00
refactor: 将 extensionsDataFolder 和 extensionsPath 移动到构造器中.
将上述属性移动之后, 可以更方便地编写测试, 也可以更加灵活地设置扩展路径.
This commit is contained in:
parent
47ca81188c
commit
e7fa80686a
@ -20,8 +20,11 @@ import java.util.concurrent.atomic.AtomicInteger
|
||||
import java.util.jar.JarEntry
|
||||
import java.util.jar.JarInputStream
|
||||
|
||||
internal class ExtensionLoader(private val bot: ScalaBot) {
|
||||
|
||||
internal class ExtensionLoader(
|
||||
private val bot: ScalaBot,
|
||||
private val extensionsDataFolder: File = AppPaths.DATA_EXTENSIONS.file,
|
||||
private val extensionsPath: File = AppPaths.EXTENSIONS.file
|
||||
) {
|
||||
private val log = KotlinLogging.logger { }
|
||||
|
||||
private val finders: Set<ExtensionPackageFinder> = setOf(
|
||||
@ -100,7 +103,7 @@ internal class ExtensionLoader(private val bot: ScalaBot) {
|
||||
|
||||
private fun getExtensionDataFolder(extensionArtifact: Artifact): File {
|
||||
val dataFolder =
|
||||
File(AppPaths.DATA_EXTENSIONS.file, "${extensionArtifact.groupId}/${extensionArtifact.artifactId}")
|
||||
File(extensionsDataFolder, "${extensionArtifact.groupId}/${extensionArtifact.artifactId}")
|
||||
if (!dataFolder.exists()) {
|
||||
dataFolder.mkdirs()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user