Remove factbook caching
authorLanius Trolling <lanius@laniustrolling.dev>
Sat, 4 Nov 2023 13:07:52 +0000 (09:07 -0400)
committerLanius Trolling <lanius@laniustrolling.dev>
Sat, 4 Nov 2023 13:07:52 +0000 (09:07 -0400)
src/main/kotlin/info/mechyrdia/Factbooks.kt
src/main/kotlin/info/mechyrdia/lore/views_lore.kt

index d98cbf3a6fa00f8181a28dc246c4d2ea64968b05..fbc99432f65338c3c9ec10f3ce8c201cf9ddf484 100644 (file)
@@ -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()
                }
        }
        
index 2c3ecad84781474ace6790c760e232b258d0626b..092e08778ec704956902e5e03a3468d6c9c772b2 100644 (file)
@@ -23,18 +23,6 @@ data class IntroMetaData(
                get() = OpenGraphData(desc, image)
 }
 
-val FactbookLastModifiedAttributeKey = AttributeKey<Instant>("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() })