mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-23 08:10:15 +01:00
Fix overflow on media cache size
This commit is contained in:
parent
b8fad693f3
commit
ad8809196f
@ -117,5 +117,5 @@ interface FileService {
|
||||
/**
|
||||
* Get size of cached files
|
||||
*/
|
||||
fun getCacheSize(): Int
|
||||
fun getCacheSize(): Long
|
||||
}
|
||||
|
@ -323,13 +323,13 @@ internal class DefaultFileService @Inject constructor(
|
||||
return FileProvider.getUriForFile(context, authority, targetFile)
|
||||
}
|
||||
|
||||
override fun getCacheSize(): Int {
|
||||
override fun getCacheSize(): Long {
|
||||
return downloadFolder.walkTopDown()
|
||||
.onEnter {
|
||||
Timber.v("Get size of ${it.absolutePath}")
|
||||
true
|
||||
}
|
||||
.sumOf { it.length().toInt() }
|
||||
.sumOf { it.length() }
|
||||
}
|
||||
|
||||
override fun clearCache() {
|
||||
|
@ -125,11 +125,11 @@ fun getFileExtension(fileUri: String): String? {
|
||||
* Size
|
||||
* ========================================================================================== */
|
||||
|
||||
fun getSizeOfFiles(root: File): Int {
|
||||
fun getSizeOfFiles(root: File): Long {
|
||||
return root.walkTopDown()
|
||||
.onEnter {
|
||||
Timber.v("Get size of ${it.absolutePath}")
|
||||
true
|
||||
}
|
||||
.sumOf { it.length().toInt() }
|
||||
.sumOf { it.length() }
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ class VectorSettingsGeneralFragment @Inject constructor(
|
||||
Glide.get(requireContext()).clearMemory()
|
||||
session.fileService().clearCache()
|
||||
|
||||
var newSize: Int
|
||||
var newSize: Long
|
||||
|
||||
withContext(Dispatchers.IO) {
|
||||
// On BG thread
|
||||
@ -261,7 +261,7 @@ class VectorSettingsGeneralFragment @Inject constructor(
|
||||
newSize += session.fileService().getCacheSize()
|
||||
}
|
||||
|
||||
it.summary = TextUtils.formatFileSize(requireContext(), newSize.toLong())
|
||||
it.summary = TextUtils.formatFileSize(requireContext(), newSize)
|
||||
|
||||
hideLoadingView()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user