PGPKeyImportActivity: close key stream after use

This commit is contained in:
Harsh Shandilya
2022-07-17 00:27:55 +05:30
parent d646415977
commit 6ceedc049c

View File

@@ -34,7 +34,7 @@ class PGPKeyImportActivity : AppCompatActivity() {
val keyInputStream = val keyInputStream =
contentResolver.openInputStream(uri) contentResolver.openInputStream(uri)
?: throw IllegalStateException("Failed to open selected file") ?: throw IllegalStateException("Failed to open selected file")
val bytes = keyInputStream.readBytes() val bytes = keyInputStream.use { `is` -> `is`.readBytes() }
val (key, error) = runBlocking { keyManager.addKey(PGPKey(bytes)) } val (key, error) = runBlocking { keyManager.addKey(PGPKey(bytes)) }
if (error != null) throw error if (error != null) throw error
key key