Fix invalidation issues when changing --side without updating pack

This commit is contained in:
comp500 2023-10-23 23:36:17 +01:00
parent b2421cfea7
commit c9543f74ee

View File

@ -127,8 +127,11 @@ class UpdateManager internal constructor(private val opts: Options, val ui: IUse
ui.submitProgress(InstallProgress("Checking local files..."))
// Invalidation checking must be done here, as it must happen before pack/index hashes are checked
// If the side changes, invalidate EVERYTHING (even when the index hasn't changed)
val invalidateAll = opts.side != manifest.cachedSide
val invalidatedUris: MutableList<PackwizFilePath> = ArrayList()
if (!invalidateAll) {
// Invalidation checking must be done here, as it must happen before pack/index hashes are checked
for ((fileUri, file) in manifest.cachedFiles) {
// ignore onlyOtherSide files
if (file.onlyOtherSide) {
@ -163,6 +166,7 @@ class UpdateManager internal constructor(private val opts: Options, val ui: IUse
return
}
}
}
Log.info("Modpack name: ${pf.name}")
@ -177,6 +181,7 @@ class UpdateManager internal constructor(private val opts: Options, val ui: IUse
pf.index.hashFormat,
manifest,
invalidatedUris,
invalidateAll,
clientHolder
)
} catch (e1: Exception) {
@ -202,7 +207,8 @@ class UpdateManager internal constructor(private val opts: Options, val ui: IUse
}
}
private fun processIndex(indexUri: PackwizPath<*>, indexHash: Hash<*>, hashFormat: HashFormat<*>, manifest: ManifestFile, invalidatedFiles: List<PackwizFilePath>, clientHolder: ClientHolder) {
private fun processIndex(indexUri: PackwizPath<*>, indexHash: Hash<*>, hashFormat: HashFormat<*>, manifest: ManifestFile, invalidatedFiles: List<PackwizFilePath>, invalidateAll: Boolean, clientHolder: ClientHolder) {
if (!invalidateAll) {
if (manifest.indexFileHash == indexHash && invalidatedFiles.isEmpty()) {
ui.submitProgress(InstallProgress("Modpack files are already up to date!", 1, 1))
if (manifest.cachedFiles.any { it.value.isOptional }) {
@ -216,6 +222,7 @@ class UpdateManager internal constructor(private val opts: Options, val ui: IUse
return
}
}
}
manifest.indexFileHash = indexHash
val indexFileSource = try {
@ -281,9 +288,6 @@ class UpdateManager internal constructor(private val opts: Options, val ui: IUse
Log.warn("Index is empty!")
}
val tasks = createTasksFromIndex(indexFile, opts.side)
// If the side changes, invalidate EVERYTHING just in case
// Might not be needed, but done just to be safe
val invalidateAll = opts.side != manifest.cachedSide
if (invalidateAll) {
Log.info("Side changed, invalidating all mods")
}