From: Lanius Trolling Date: Sat, 4 Nov 2023 13:07:52 +0000 (-0400) Subject: Remove factbook caching X-Git-Url: https://gitweb.starshipfights.net/?a=commitdiff_plain;h=1b67aa6141fb7723994608fdf28d3a11bd296ff2;p=factbooks Remove factbook caching --- diff --git a/src/main/kotlin/info/mechyrdia/Factbooks.kt b/src/main/kotlin/info/mechyrdia/Factbooks.kt index d98cbf3..fbc9943 100644 --- a/src/main/kotlin/info/mechyrdia/Factbooks.kt +++ b/src/main/kotlin/info/mechyrdia/Factbooks.kt @@ -54,7 +54,8 @@ fun Application.factbooks() { CachingOptions(CacheControl.MaxAge(maxAgeSeconds = 3600)) else if (call.attributes.getOrNull(PageDoNotCacheAttributeKey) == true) CachingOptions(CacheControl.NoStore(null)) - else null + else + null } } @@ -62,9 +63,8 @@ fun Application.factbooks() { version { call, outgoingContent -> if (outgoingContent is LocalFileContent) listOf(LastModifiedVersion(outgoingContent.file.lastModified())) - else call.attributes.getOrNull(FactbookLastModifiedAttributeKey)?.let { lastModified -> - listOf(LastModifiedVersion(lastModified.toEpochMilli())) - } ?: emptyList() + else + emptyList() } } diff --git a/src/main/kotlin/info/mechyrdia/lore/views_lore.kt b/src/main/kotlin/info/mechyrdia/lore/views_lore.kt index 2c3ecad..092e087 100644 --- a/src/main/kotlin/info/mechyrdia/lore/views_lore.kt +++ b/src/main/kotlin/info/mechyrdia/lore/views_lore.kt @@ -23,18 +23,6 @@ data class IntroMetaData( get() = OpenGraphData(desc, image) } -val FactbookLastModifiedAttributeKey = AttributeKey("Mechyrdia.FactbookLastModified") - -private val File.lastSubFilesModified: Instant? - get() = if (isDirectory) - (listFiles()!!.mapNotNull { - it.lastSubFilesModified - } + Instant.ofEpochMilli(lastModified())!!).max() - else null - -private val File.lastContentModified: Instant - get() = lastSubFilesModified ?: Instant.ofEpochMilli(lastModified())!! - suspend fun ApplicationCall.loreIntroPage(): HTML.() -> Unit { val metaJsonFile = File(Configuration.CurrentConfiguration.articleDir).parentFile.combineSafe("introMeta.json") val metaData = JsonFileCodec.decodeFromString(IntroMetaData.serializer(), metaJsonFile.readText()) @@ -42,14 +30,6 @@ suspend fun ApplicationCall.loreIntroPage(): HTML.() -> Unit { val htmlFile = File(Configuration.CurrentConfiguration.articleDir).parentFile.combineSafe("intro.html") val fileHtml = htmlFile.readText() - attributes.put( - FactbookLastModifiedAttributeKey, - maxOf( - Instant.ofEpochMilli(htmlFile.lastModified()), - Instant.ofEpochMilli(metaJsonFile.lastModified()) - ) - ) - return page(metaData.title, standardNavBar(), null, metaData.ogData) { section { a { id = "page-top" } @@ -75,13 +55,6 @@ suspend fun ApplicationCall.loreArticlePage(): HTML.() -> Unit { canCommentAs.await() to comments.await() } - if (pageFile.exists()) - attributes.put(FactbookLastModifiedAttributeKey, - (comments.map { comment -> - comment.lastEdit ?: comment.submittedAt - } + pageFile.lastContentModified).max() - ) - if (pageFile.isDirectory) { val navbar = standardNavBar(pagePathParts.takeIf { it.isNotEmpty() })