Fix optional and sided mod filtering properly

This commit is contained in:
comp500 2022-05-23 20:32:22 +01:00
parent c2ee6fca8b
commit 858fd17f3e

View File

@ -180,17 +180,19 @@ internal class DownloadTask private constructor(val metadata: IndexFile.File, de
fun download(packFolder: String, indexUri: SpaceSafeURI) { fun download(packFolder: String, indexUri: SpaceSafeURI) {
if (err != null) return if (err != null) return
// Ensure wrong-side or optional false files are removed // Exclude wrong-side and optional false files
cachedFile?.let { cachedFile?.let {
if ((it.isOptional && !it.optionValue) || !correctSide()) { if ((it.isOptional && !it.optionValue) || !correctSide()) {
if (it.cachedLocation != null) { if (it.cachedLocation != null) {
// Ensure wrong-side or optional false files are removed
try { try {
Files.deleteIfExists(Paths.get(packFolder, it.cachedLocation)) Files.deleteIfExists(Paths.get(packFolder, it.cachedLocation))
} catch (e: IOException) { } catch (e: IOException) {
Log.warn("Failed to delete file before downloading", e) Log.warn("Failed to delete file", e)
} }
} }
it.cachedLocation = null it.cachedLocation = null
return
} }
} }
if (alreadyUpToDate) return if (alreadyUpToDate) return