mirror of
https://github.com/packwiz/packwiz-installer.git
synced 2025-10-16 16:04:32 +02:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
4b3c279e71 | ||
|
b413371306 | ||
|
1d2ec61232 |
6
.idea/compiler.xml
generated
Normal file
6
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="1.8" />
|
||||
</component>
|
||||
</project>
|
2
.idea/packwiz-installer.iml
generated
Normal file
2
.idea/packwiz-installer.iml
generated
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4" />
|
@@ -1,3 +1,5 @@
|
||||
@file:JvmName("Main")
|
||||
|
||||
package link.infra.packwiz.installer
|
||||
|
||||
import link.infra.packwiz.installer.metadata.SpaceSafeURI
|
||||
|
@@ -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) {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package link.infra.packwiz.installer.request
|
||||
|
||||
import link.infra.packwiz.installer.metadata.SpaceSafeURI
|
||||
import link.infra.packwiz.installer.request.handlers.RequestHandlerFile
|
||||
import link.infra.packwiz.installer.request.handlers.RequestHandlerGithub
|
||||
import link.infra.packwiz.installer.request.handlers.RequestHandlerHTTP
|
||||
import okio.Source
|
||||
@@ -9,7 +10,8 @@ object HandlerManager {
|
||||
|
||||
private val handlers: List<IRequestHandler> = listOf(
|
||||
RequestHandlerGithub(),
|
||||
RequestHandlerHTTP()
|
||||
RequestHandlerHTTP(),
|
||||
RequestHandlerFile()
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
@@ -0,0 +1,18 @@
|
||||
package link.infra.packwiz.installer.request.handlers
|
||||
|
||||
import link.infra.packwiz.installer.metadata.SpaceSafeURI
|
||||
import link.infra.packwiz.installer.request.IRequestHandler
|
||||
import okio.Source
|
||||
import okio.source
|
||||
import java.nio.file.Paths
|
||||
|
||||
open class RequestHandlerFile : IRequestHandler {
|
||||
override fun matchesHandler(loc: SpaceSafeURI): Boolean {
|
||||
return "file" == loc.scheme
|
||||
}
|
||||
|
||||
override fun getFileSource(loc: SpaceSafeURI): Source? {
|
||||
val path = Paths.get(loc.toURL().toURI())
|
||||
return path.source()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user