mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +03:00
Fix potential leak
Signed-off-by: Dominic Fischer <dominicfischer7@gmail.com>
This commit is contained in:
parent
6d01a570fd
commit
b59017938b
1 changed files with 2 additions and 5 deletions
|
@ -26,11 +26,8 @@ import java.io.InputStream
|
||||||
*/
|
*/
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
fun writeToFile(inputStream: InputStream, outputFile: File) {
|
fun writeToFile(inputStream: InputStream, outputFile: File) {
|
||||||
val source = Okio.buffer(Okio.source(inputStream))
|
Okio.buffer(Okio.source(inputStream)).use { input ->
|
||||||
val sink = Okio.buffer(Okio.sink(outputFile))
|
Okio.buffer(Okio.sink(outputFile)).use { output ->
|
||||||
|
|
||||||
source.use { input ->
|
|
||||||
sink.use { output ->
|
|
||||||
output.writeAll(input)
|
output.writeAll(input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue