Fix overflow
authorLanius Trolling <lanius@laniustrolling.dev>
Wed, 10 Apr 2024 23:40:45 +0000 (19:40 -0400)
committerLanius Trolling <lanius@laniustrolling.dev>
Wed, 10 Apr 2024 23:40:45 +0000 (19:40 -0400)
src/jvmMain/kotlin/info/mechyrdia/lore/asset_caching.kt

index 8c6d1f6d4952456260f66a8d1c87f259bdea4186..f4e3da92b837101af676b8f9e9548dfd446d71be 100644 (file)
@@ -17,7 +17,7 @@ val StoragePathAttributeKey = AttributeKey<StoragePath>("Mechyrdia.StoragePath")
 
 abstract class FileDependentCache<T : Any> {
        private inner class Entry(updated: Instant?, data: T?) {
-               private val updatedAtomic = AtomicLong((updated ?: Instant.MIN).toEpochMilli())
+               private val updatedAtomic = AtomicLong(updated?.toEpochMilli() ?: Long.MIN_VALUE)
                val updated: Instant
                        get() = Instant.ofEpochMilli(updatedAtomic.get())
                
@@ -28,7 +28,7 @@ abstract class FileDependentCache<T : Any> {
                private val updateLock = Mutex()
                
                private fun clear() {
-                       updatedAtomic.set(Instant.MIN.toEpochMilli())
+                       updatedAtomic.set(Long.MIN_VALUE)
                        dataAtomic.set(null)
                }