mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Don't leak MediaFileHandle when downloading voice messages (#1748)
Uses the new `MediaFile.persist()` [API](https://github.com/matrix-org/matrix-rust-sdk/pull/2789) to cache voice messages. This allows to close the `MediaFile` handle after use and keeping the file. Also disables rust sdk caching for voice messages as we'll use the app's cache dir for that purpose. Fixes: https://github.com/vector-im/element-meta/issues/2175
This commit is contained in:
+5
@@ -17,11 +17,16 @@
|
||||
package io.element.android.libraries.matrix.test.media
|
||||
|
||||
import io.element.android.libraries.matrix.api.media.MediaFile
|
||||
import java.io.File
|
||||
|
||||
class FakeMediaFile(private val path: String) : MediaFile {
|
||||
override fun path(): String {
|
||||
return path
|
||||
}
|
||||
|
||||
override fun persist(path: String): Boolean {
|
||||
return File(path()).renameTo(File(path))
|
||||
}
|
||||
|
||||
override fun close() = Unit
|
||||
}
|
||||
|
||||
+6
-1
@@ -42,7 +42,12 @@ class FakeMediaLoader : MatrixMediaLoader {
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun downloadMediaFile(source: MediaSource, mimeType: String?, body: String?): Result<MediaFile> = simulateLongTask {
|
||||
override suspend fun downloadMediaFile(
|
||||
source: MediaSource,
|
||||
mimeType: String?,
|
||||
body: String?,
|
||||
useCache: Boolean,
|
||||
): Result<MediaFile> = simulateLongTask {
|
||||
if (shouldFail) {
|
||||
Result.failure(RuntimeException())
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user