mirror of
https://github.com/packwiz/packwiz-installer.git
synced 2025-04-19 21:16:30 +02:00
Show download exceptions properly in CLI
This commit is contained in:
parent
60887a4312
commit
f52cd19ad4
@ -152,6 +152,9 @@ internal class DownloadTask private constructor(val metadata: IndexFile.File, de
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: if already exists and has correct hash, ignore?
|
||||||
|
// TODO: add .disabled support?
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val hash: Hash
|
val hash: Hash
|
||||||
val fileHashFormat: String
|
val fileHashFormat: String
|
||||||
@ -177,8 +180,12 @@ internal class DownloadTask private constructor(val metadata: IndexFile.File, de
|
|||||||
|
|
||||||
if (fileSource.hashIsEqual(hash)) {
|
if (fileSource.hashIsEqual(hash)) {
|
||||||
// isDirectory follows symlinks, but createDirectories doesn't
|
// isDirectory follows symlinks, but createDirectories doesn't
|
||||||
if (!Files.isDirectory(destPath.parent)) {
|
try {
|
||||||
Files.createDirectories(destPath.parent)
|
Files.createDirectories(destPath.parent)
|
||||||
|
} catch (e: FileAlreadyExistsException) {
|
||||||
|
if (!Files.isDirectory(destPath.parent)) {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Files.copy(data.inputStream(), destPath, StandardCopyOption.REPLACE_EXISTING)
|
Files.copy(data.inputStream(), destPath, StandardCopyOption.REPLACE_EXISTING)
|
||||||
data.clear()
|
data.clear()
|
||||||
|
@ -3,6 +3,7 @@ package link.infra.packwiz.installer.ui
|
|||||||
import link.infra.packwiz.installer.ui.IUserInterface.ExceptionListResult
|
import link.infra.packwiz.installer.ui.IUserInterface.ExceptionListResult
|
||||||
import java.util.concurrent.CompletableFuture
|
import java.util.concurrent.CompletableFuture
|
||||||
import java.util.concurrent.Future
|
import java.util.concurrent.Future
|
||||||
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
class CLIHandler : IUserInterface {
|
class CLIHandler : IUserInterface {
|
||||||
override fun handleException(e: Exception) {
|
override fun handleException(e: Exception) {
|
||||||
@ -40,8 +41,11 @@ class CLIHandler : IUserInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showExceptions(exceptions: List<ExceptionDetails>, numTotal: Int, allowsIgnore: Boolean): Future<ExceptionListResult> {
|
override fun showExceptions(exceptions: List<ExceptionDetails>, numTotal: Int, allowsIgnore: Boolean): Future<ExceptionListResult> {
|
||||||
val future = CompletableFuture<ExceptionListResult>()
|
println("Failed to download modpack, the following errors were encountered:")
|
||||||
future.complete(ExceptionListResult.CANCEL)
|
for (ex in exceptions) {
|
||||||
return future
|
println(ex.name + ": ")
|
||||||
|
ex.exception.printStackTrace()
|
||||||
|
}
|
||||||
|
exitProcess(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user