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 746699b468
commit b219c05d06
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()
}