From 35fd9af24f3738a3b20b3032dddca09de4e03d11 Mon Sep 17 00:00:00 2001 From: Mike Nakhimovich Date: Thu, 6 May 2021 11:45:17 -0400 Subject: [PATCH] Remove deprecated code to fix error when users upgrade to kotlin 1.5 (#265) * upgrade to kotlin 1.5 warning breaking change * achieve compatibility with 1.4 and 1.5 * trigger travis * fix lint Co-authored-by: miken --- README.md | 2 +- .../android/external/fs3/filesystem/FileSystemImpl.kt | 3 ++- .../com/dropbox/android/external/store4/StoreDefaults.kt | 5 +++-- .../com/dropbox/android/external/store4/impl/RealStore.kt | 5 +++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index dd8b6a5..d977e0c 100644 --- a/README.md +++ b/README.md @@ -282,7 +282,7 @@ StoreBuilder The following will clear the entry associated with the key from both the in-memory cache and the sourceOfTruth: ```kotlin -store.clear("10") +store.clear("myKey") ``` The following will clear all entries from both the in-memory cache and the sourceOfTruth: diff --git a/filesystem/src/main/java/com/dropbox/android/external/fs3/filesystem/FileSystemImpl.kt b/filesystem/src/main/java/com/dropbox/android/external/fs3/filesystem/FileSystemImpl.kt index f7ec8d0..aacdfa5 100644 --- a/filesystem/src/main/java/com/dropbox/android/external/fs3/filesystem/FileSystemImpl.kt +++ b/filesystem/src/main/java/com/dropbox/android/external/fs3/filesystem/FileSystemImpl.kt @@ -9,6 +9,7 @@ import java.io.File import java.io.FileNotFoundException import java.io.IOException import kotlin.time.Duration +import kotlin.time.DurationUnit import kotlin.time.ExperimentalTime /** @@ -74,7 +75,7 @@ internal class FileSystemImpl(private val root: File) : FileSystem { return RecordState.MISSING } val now = System.currentTimeMillis() - val cuttOffPoint = now - expirationDuration.toLongMilliseconds() + val cuttOffPoint = now - expirationDuration.toLong(DurationUnit.MILLISECONDS) return if (file.lastModified() < cuttOffPoint) { RecordState.STALE } else { diff --git a/store/src/main/java/com/dropbox/android/external/store4/StoreDefaults.kt b/store/src/main/java/com/dropbox/android/external/store4/StoreDefaults.kt index ede5cdc..4fe67fe 100644 --- a/store/src/main/java/com/dropbox/android/external/store4/StoreDefaults.kt +++ b/store/src/main/java/com/dropbox/android/external/store4/StoreDefaults.kt @@ -1,8 +1,9 @@ package com.dropbox.android.external.store4 import kotlin.time.Duration +import kotlin.time.DurationUnit import kotlin.time.ExperimentalTime -import kotlin.time.hours +import kotlin.time.toDuration @ExperimentalTime internal object StoreDefaults { @@ -12,7 +13,7 @@ internal object StoreDefaults { * * @return memory cache TTL */ - val cacheTTL: Duration = 24.hours + val cacheTTL: Duration = 24.toDuration(DurationUnit.HOURS) /** * Cache size (default is 100), can be overridden diff --git a/store/src/main/java/com/dropbox/android/external/store4/impl/RealStore.kt b/store/src/main/java/com/dropbox/android/external/store4/impl/RealStore.kt index e996bfe..6926dda 100644 --- a/store/src/main/java/com/dropbox/android/external/store4/impl/RealStore.kt +++ b/store/src/main/java/com/dropbox/android/external/store4/impl/RealStore.kt @@ -38,6 +38,7 @@ import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.transform import java.util.concurrent.TimeUnit +import kotlin.time.DurationUnit import kotlin.time.ExperimentalTime @ExperimentalTime @@ -65,13 +66,13 @@ internal class RealStore( CacheBuilder.newBuilder().apply { if (memoryPolicy.hasAccessPolicy) { expireAfterAccess( - memoryPolicy.expireAfterAccess.toLongMilliseconds(), + memoryPolicy.expireAfterAccess.toLong(DurationUnit.MILLISECONDS), TimeUnit.MILLISECONDS ) } if (memoryPolicy.hasWritePolicy) { expireAfterWrite( - memoryPolicy.expireAfterWrite.toLongMilliseconds(), + memoryPolicy.expireAfterWrite.toLong(DurationUnit.MILLISECONDS), TimeUnit.MILLISECONDS ) }