Fixed unable to download files without extension
This commit is contained in:
@@ -68,10 +68,8 @@ class NetworkCache(context: Context) : DIAware {
|
|||||||
private val activeFilesMutex = Mutex()
|
private val activeFilesMutex = Mutex()
|
||||||
private val activeFiles = Collections.newSetFromMap(ConcurrentHashMap<String, Boolean>())
|
private val activeFiles = Collections.newSetFromMap(ConcurrentHashMap<String, Boolean>())
|
||||||
|
|
||||||
private fun urlToFilename(url: String): String {
|
private fun urlToFilename(url: String): String =
|
||||||
val hash = sha256(url.toByteArray()).joinToString("") { "%02x".format(it) }
|
sha256(url.toByteArray()).joinToString("") { "%02x".format(it) }
|
||||||
return "$hash.${url.takeLastWhile { it != '.' }}"
|
|
||||||
}
|
|
||||||
|
|
||||||
fun cleanup() = CoroutineScope(Dispatchers.IO).launch {
|
fun cleanup() = CoroutineScope(Dispatchers.IO).launch {
|
||||||
if (cacheDir.size() > CACHE_LIMIT)
|
if (cacheDir.size() > CACHE_LIMIT)
|
||||||
@@ -160,6 +158,7 @@ class NetworkCache(context: Context) : DIAware {
|
|||||||
progressFlow.emit(Float.POSITIVE_INFINITY)
|
progressFlow.emit(Float.POSITIVE_INFINITY)
|
||||||
}
|
}
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
|
logger.warning(it)
|
||||||
file.delete()
|
file.delete()
|
||||||
FirebaseCrashlytics.getInstance().recordException(it)
|
FirebaseCrashlytics.getInstance().recordException(it)
|
||||||
progressFlow.emit(Float.NEGATIVE_INFINITY)
|
progressFlow.emit(Float.NEGATIVE_INFINITY)
|
||||||
|
|||||||
Reference in New Issue
Block a user