Make sure we clean up the pre-processed and uploaded media (#5039)

* Add `MediaSender.cleanUp()` and `MediaPreProcessor.cleanUp()` methods: this will remove the temporary files created when pre-processing media before sending them.

* Make sure we clean up also the previous temporary media.

* Fix the condition for the custom back handler in the attachments preview screen

* Tests: check the clean up is performed when needed
This commit is contained in:
Jorge Martin Espinosa 2025-07-23 08:55:20 +02:00 committed by GitHub
parent 9f11884ddd
commit d53457ec66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 65 additions and 8 deletions

View file

@ -22,5 +22,10 @@ interface MediaPreProcessor {
compressIfPossible: Boolean,
): Result<MediaUploadInfo>
/**
* Clean up any temporary files or resources used during the media processing.
*/
fun cleanUp()
data class Failure(override val cause: Throwable?) : Exception(cause)
}

View file

@ -200,4 +200,9 @@ class MediaSender @Inject constructor(
uploadHandler.await()
}
}
/**
* Clean up any temporary files or resources used during the media processing.
*/
fun cleanUp() = preProcessor.cleanUp()
}