Signed-off-by: Graham <gpe@openrs2.org>
@ -199,6 +199,25 @@ public class CacheExporter @Inject constructor(
val key: XteaKey
)
public suspend fun totalSize(): Long {
return database.execute { connection ->
connection.prepareStatement(
"""
SELECT SUM(size)
FROM cache_stats
""".trimIndent()
).use { stmt ->
stmt.executeQuery().use { rows ->
if (rows.next()) {
rows.getLong(1)
} else {
0
}
public suspend fun list(): List<CacheSummary> {
@ -50,7 +50,15 @@ public class CachesController @Inject constructor(
public suspend fun index(call: ApplicationCall) {
val caches = exporter.list()
call.respond(ThymeleafContent("caches/index.html", mapOf("caches" to caches)))
val totalSize = exporter.totalSize()
call.respond(
ThymeleafContent(
"caches/index.html", mapOf(
"caches" to caches,
"totalSize" to totalSize
public suspend fun indexJson(call: ApplicationCall) {
@ -110,6 +110,10 @@
</tbody>
</table>
</div>
<p>
The total size of all caches in the archive is
<strong th:text="${#byteunits.format(totalSize)}">0 B</strong>.
</p>
<sup id="empty-locs">1</sup> Map squares in the middle of the
sea are unreachable by normal players, making it impossible to