mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Merge pull request #5396 from tgloureiro/develop
Fix Media cache size with negative values in the General Settings screen
This commit is contained in:
commit
d4caad1665
1
changelog.d/5394.bugfix
Normal file
1
changelog.d/5394.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Fix incorrect media cache size in settings
|
@ -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