Compare commits

..

5 Commits

Author SHA1 Message Date
comp500
f52cd19ad4 Show download exceptions properly in CLI 2020-12-11 18:18:10 +00:00
comp500
60887a4312 Whoops 2020-12-07 17:42:52 +00:00
comp500
a368268038 Fix support for symlinked directories 2020-12-07 17:38:21 +00:00
comp500
8beded7b41 Improve UX when there are no optional mods 2020-12-06 19:05:56 +00:00
comp500
91060dcd54 Put an error message there. Later is now! 2020-11-30 00:24:47 +00:00
4 changed files with 30 additions and 10 deletions

View File

@@ -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
@@ -176,7 +179,14 @@ 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
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()
} else { } else {

View File

@@ -255,8 +255,7 @@ class UpdateManager internal constructor(private val opts: Options, val ui: IUse
return return
} }
if (!indexFileSource.hashIsEqual(indexHash)) { if (!indexFileSource.hashIsEqual(indexHash)) {
// TODO: throw exception ui.handleExceptionAndExit(RuntimeException("Your index hash is invalid! Please run packwiz refresh on the pack again"))
println("I was meant to put an error message here but I'll do that later")
return return
} }
if (stateHandler.cancelButton) { if (stateHandler.cancelButton) {

View File

@@ -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)
} }
} }

View File

@@ -180,11 +180,18 @@ class InstallWindow : IUserInterface {
override fun showOptions(options: List<IOptionDetails>): Future<Boolean> { override fun showOptions(options: List<IOptionDetails>): Future<Boolean> {
val future = CompletableFuture<Boolean>() val future = CompletableFuture<Boolean>()
EventQueue.invokeLater { EventQueue.invokeLater {
if (options.isEmpty()) {
JOptionPane.showMessageDialog(null,
"This modpack has no optional mods!",
"Optional mods", JOptionPane.INFORMATION_MESSAGE)
future.complete(false)
} else {
OptionsSelectWindow(options, future, frmPackwizlauncher).apply { OptionsSelectWindow(options, future, frmPackwizlauncher).apply {
defaultCloseOperation = JDialog.DISPOSE_ON_CLOSE defaultCloseOperation = JDialog.DISPOSE_ON_CLOSE
isVisible = true isVisible = true
} }
} }
}
return future return future
} }
@@ -201,7 +208,7 @@ class InstallWindow : IUserInterface {
override fun disableOptionsButton() { override fun disableOptionsButton() {
btnOptions.apply { btnOptions.apply {
text = "Optional mods..." text = "No optional mods"
isEnabled = false isEnabled = false
} }
} }