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
No known key found for this signature in database
GPG Key ID: 366D7BBAD1031E80

View File

@ -34,7 +34,7 @@ class PGPKeyImportActivity : AppCompatActivity() {
val keyInputStream =
contentResolver.openInputStream(uri)
?: 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)) }
if (error != null) throw error
key