Minor cleanup
This commit is contained in:
@@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.data.download
|
||||
import android.content.Context
|
||||
import androidx.core.net.toUri
|
||||
import com.hippo.unifile.UniFile
|
||||
import eu.kanade.core.util.mapNotNullKeys
|
||||
import eu.kanade.domain.download.service.DownloadPreferences
|
||||
import eu.kanade.domain.manga.model.Manga
|
||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||
@@ -68,9 +69,7 @@ class DownloadCache(
|
||||
downloadPreferences.downloadsDirectory().changes()
|
||||
.onEach {
|
||||
rootDownloadsDir = RootDirectory(getDirectoryFromPreference())
|
||||
|
||||
// Invalidate cache
|
||||
lastRenew = 0L
|
||||
invalidateCache()
|
||||
}
|
||||
.launchIn(scope)
|
||||
}
|
||||
@@ -225,6 +224,10 @@ class DownloadCache(
|
||||
notifyChanges()
|
||||
}
|
||||
|
||||
fun invalidateCache() {
|
||||
lastRenew = 0L
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the downloads directory from the user's preferences.
|
||||
*/
|
||||
@@ -233,10 +236,6 @@ class DownloadCache(
|
||||
return UniFile.fromUri(context, dir.toUri())
|
||||
}
|
||||
|
||||
fun invalidateCache() {
|
||||
lastRenew = 0L
|
||||
}
|
||||
|
||||
/**
|
||||
* Renews the downloads cache.
|
||||
*/
|
||||
@@ -315,15 +314,6 @@ class DownloadCache(
|
||||
_changes.send(Unit)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new map containing only the key entries of [transform] that are not null.
|
||||
*/
|
||||
private inline fun <K, V, R> Map<out K, V>.mapNotNullKeys(transform: (Map.Entry<K?, V>) -> R?): ConcurrentHashMap<R, V> {
|
||||
val mutableMap = ConcurrentHashMap<R, V>()
|
||||
forEach { element -> transform(element)?.let { mutableMap[it] = element.value } }
|
||||
return mutableMap
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user