mirror of
https://github.com/packwiz/packwiz-installer.git
synced 2025-04-19 21:16:30 +02:00
Always use UTF-8 for reading TOML files (fixes #22)
This commit is contained in:
parent
07af6046c1
commit
92d6f68f1d
@ -22,10 +22,7 @@ import link.infra.packwiz.installer.ui.data.InstallProgress
|
|||||||
import link.infra.packwiz.installer.util.Log
|
import link.infra.packwiz.installer.util.Log
|
||||||
import link.infra.packwiz.installer.util.ifletOrErr
|
import link.infra.packwiz.installer.util.ifletOrErr
|
||||||
import okio.buffer
|
import okio.buffer
|
||||||
import java.io.FileNotFoundException
|
import java.io.*
|
||||||
import java.io.FileReader
|
|
||||||
import java.io.FileWriter
|
|
||||||
import java.io.IOException
|
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
import java.util.concurrent.CompletionService
|
import java.util.concurrent.CompletionService
|
||||||
@ -88,7 +85,7 @@ class UpdateManager internal constructor(private val opts: Options, val ui: IUse
|
|||||||
}
|
}
|
||||||
val pf = packFileSource.buffer().use {
|
val pf = packFileSource.buffer().use {
|
||||||
try {
|
try {
|
||||||
Toml().read(it.inputStream()).to(PackFile::class.java)
|
Toml().read(InputStreamReader(it.inputStream(), "UTF-8")).to(PackFile::class.java)
|
||||||
} catch (e: IllegalStateException) {
|
} catch (e: IllegalStateException) {
|
||||||
ui.showErrorAndExit("Failed to parse pack.toml", e)
|
ui.showErrorAndExit("Failed to parse pack.toml", e)
|
||||||
}
|
}
|
||||||
@ -201,7 +198,7 @@ class UpdateManager internal constructor(private val opts: Options, val ui: IUse
|
|||||||
}
|
}
|
||||||
|
|
||||||
val indexFile = try {
|
val indexFile = try {
|
||||||
Toml().read(indexFileSource.buffer().inputStream()).to(IndexFile::class.java)
|
Toml().read(InputStreamReader(indexFileSource.buffer().inputStream(), "UTF-8")).to(IndexFile::class.java)
|
||||||
} catch (e: IllegalStateException) {
|
} catch (e: IllegalStateException) {
|
||||||
ui.showErrorAndExit("Failed to parse index file", e)
|
ui.showErrorAndExit("Failed to parse index file", e)
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import link.infra.packwiz.installer.request.HandlerManager.getFileSource
|
|||||||
import link.infra.packwiz.installer.request.HandlerManager.getNewLoc
|
import link.infra.packwiz.installer.request.HandlerManager.getNewLoc
|
||||||
import okio.Source
|
import okio.Source
|
||||||
import okio.buffer
|
import okio.buffer
|
||||||
|
import java.io.InputStreamReader
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
|
||||||
class IndexFile {
|
class IndexFile {
|
||||||
@ -43,7 +44,7 @@ class IndexFile {
|
|||||||
linkedFileURI = getNewLoc(indexUri, file)
|
linkedFileURI = getNewLoc(indexUri, file)
|
||||||
val src = getFileSource(linkedFileURI!!)
|
val src = getFileSource(linkedFileURI!!)
|
||||||
val fileStream = getHasher(hashFormat!!).getHashingSource(src)
|
val fileStream = getHasher(hashFormat!!).getHashingSource(src)
|
||||||
linkedFile = Toml().read(fileStream.buffer().inputStream()).to(ModFile::class.java)
|
linkedFile = Toml().read(InputStreamReader(fileStream.buffer().inputStream(), "UTF-8")).to(ModFile::class.java)
|
||||||
if (!fileStream.hashIsEqual(fileHash)) {
|
if (!fileStream.hashIsEqual(fileHash)) {
|
||||||
throw Exception("Invalid mod file hash")
|
throw Exception("Invalid mod file hash")
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import link.infra.packwiz.installer.task.CacheKey
|
|||||||
import link.infra.packwiz.installer.task.Task
|
import link.infra.packwiz.installer.task.Task
|
||||||
import link.infra.packwiz.installer.task.TaskCombinedResult
|
import link.infra.packwiz.installer.task.TaskCombinedResult
|
||||||
import link.infra.packwiz.installer.task.TaskContext
|
import link.infra.packwiz.installer.task.TaskContext
|
||||||
|
import java.io.InputStreamReader
|
||||||
|
|
||||||
class PackwizV1PackTomlTask(ctx: TaskContext, val path: PackwizPath): Task<PackwizV1PackFile>(ctx) {
|
class PackwizV1PackTomlTask(ctx: TaskContext, val path: PackwizPath): Task<PackwizV1PackFile>(ctx) {
|
||||||
// TODO: make hierarchically defined by caller? - then changing the pack format type doesn't leave junk in the cache
|
// TODO: make hierarchically defined by caller? - then changing the pack format type doesn't leave junk in the cache
|
||||||
@ -30,7 +31,7 @@ class PackwizV1PackTomlTask(ctx: TaskContext, val path: PackwizPath): Task<Packw
|
|||||||
|
|
||||||
private val internalResult by lazy {
|
private val internalResult by lazy {
|
||||||
// TODO: query, parse JSON
|
// TODO: query, parse JSON
|
||||||
val packFile = Toml().read(path.source(ctx.clients).inputStream()).to(PackFile::class.java)
|
val packFile = Toml().read(InputStreamReader(path.source(ctx.clients).inputStream(), "UTF-8")).to(PackFile::class.java)
|
||||||
|
|
||||||
val resolved = PackwizV1PackFile(packFile.name ?: throw RuntimeException("Name required"), // TODO: better exception handling
|
val resolved = PackwizV1PackFile(packFile.name ?: throw RuntimeException("Name required"), // TODO: better exception handling
|
||||||
path.resolve(packFile.index?.file ?: throw RuntimeException("File required")),
|
path.resolve(packFile.index?.file ?: throw RuntimeException("File required")),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user