Ignore trailing blocks with a non-zero next block pointer

While the client doesn't appear to be capable of producing a trailing
block with a non-zero next block pointer (though I may have misread the
code), there are caches out there in the wild with trailing non-zero
next block pointers.

When it is reading a group, the client ignores these.

Therefore, for compatibility with the client and existing caches, this
commit removes the StoreCorruptException thrown in this case.

Signed-off-by: Graham <gpe@openrs2.org>
Graham 4 years ago
parent 75d4446b92
commit b067020cad
  1. 4
      cache/src/main/kotlin/org/openrs2/cache/DiskStore.kt
  2. 17
      cache/src/test/kotlin/org/openrs2/cache/DiskStoreTest.kt

@ -196,10 +196,6 @@ public class DiskStore private constructor(
num++ num++
} while (buf.isWritable) } while (buf.isWritable)
if (block != 0) {
throw StoreCorruptException("Group longer than expected")
}
return buf.retain() return buf.retain()
} }
} }

@ -495,12 +495,6 @@ class DiskStoreTest {
@Test @Test
fun testReadCorrupt() { fun testReadCorrupt() {
readTest("corrupt-eof-late") { store ->
assertFailsWith<StoreCorruptException> {
store.read(255, 1).release()
}
}
readTest("corrupt-first-eof-early") { store -> readTest("corrupt-first-eof-early") { store ->
assertFailsWith<StoreCorruptException> { assertFailsWith<StoreCorruptException> {
store.read(255, 1).release() store.read(255, 1).release()
@ -562,6 +556,17 @@ class DiskStoreTest {
} }
} }
@Test
fun testReadCorruptEofLate() {
readTest("corrupt-eof-late") { store ->
copiedBuffer("OpenRS2".repeat(1000)).use { expected ->
store.read(255, 1).use { actual ->
assertEquals(expected, actual)
}
}
}
}
@Test @Test
fun testOverwriteCorrupt() { fun testOverwriteCorrupt() {
overwriteTest("corrupt-eof-late", "corrupt-eof-late-overwritten") { store -> overwriteTest("corrupt-eof-late", "corrupt-eof-late-overwritten") { store ->

Loading…
Cancel
Save