From 1d2ec612323997b3cd2f37609724ca56c40bab78 Mon Sep 17 00:00:00 2001 From: comp500 Date: Fri, 7 Feb 2020 03:12:52 +0000 Subject: [PATCH] Fix disgusting getNewLoc call (!! already checks null!!) --- .../infra/packwiz/installer/UpdateManager.kt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/link/infra/packwiz/installer/UpdateManager.kt b/src/main/kotlin/link/infra/packwiz/installer/UpdateManager.kt index ae687c9..3109c59 100644 --- a/src/main/kotlin/link/infra/packwiz/installer/UpdateManager.kt +++ b/src/main/kotlin/link/infra/packwiz/installer/UpdateManager.kt @@ -126,7 +126,6 @@ class UpdateManager internal constructor(private val opts: Options, val ui: IUse ui.submitProgress(InstallProgress("Loading pack file...")) val packFileSource = try { - Objects.requireNonNull(opts.downloadURI) val src = getFileSource(opts.downloadURI!!) getHasher("sha256").getHashingSource(src) } catch (e: Exception) { @@ -191,12 +190,16 @@ class UpdateManager internal constructor(private val opts: Options, val ui: IUse handleCancellation() } try { - // This is badly written, I'll probably heavily refactor it at some point - // The port to Kotlin made this REALLY messy!!!! - getNewLoc(opts.downloadURI, Objects.requireNonNull(pf.index)!!.file)?.let { - pf.index!!.hashFormat?.let { it1 -> - processIndex(it, - getHash(Objects.requireNonNull(pf.index!!.hashFormat)!!, Objects.requireNonNull(pf.index!!.hash)!!), it1, manifest, invalidatedUris) + val index = pf.index!! + getNewLoc(opts.downloadURI, index.file)?.let { newLoc -> + index.hashFormat?.let { hashFormat -> + processIndex( + newLoc, + getHash(index.hashFormat!!, index.hash!!), + hashFormat, + manifest, + invalidatedUris + ) } } } catch (e1: Exception) {