From ab964a2b1fefa4fdce2e05c101da58670ad5280f Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 11 Dec 2021 22:38:43 +0000 Subject: [PATCH] Skip corrupt files when importing a legacy cache Signed-off-by: Graham --- .../kotlin/org/openrs2/archive/cache/CacheImporter.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt index 6d64d9a4..28a2f7a7 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt @@ -1243,9 +1243,14 @@ public class CacheImporter @Inject constructor( } private fun readFile(store: Store, index: Int, file: Int): File? { - store.read(index, file).use { buf -> - val version = VersionTrailer.strip(buf) ?: return null - return File(index, file, buf.retain(), version) + try { + store.read(index, file).use { buf -> + val version = VersionTrailer.strip(buf) ?: return null + return File(index, file, buf.retain(), version) + } + } catch (ex: IOException) { + logger.warn(ex) { "Skipping corrupt file (index $index, group $file)" } + return null } }