diff options
-rw-r--r-- | app/src/main/java/app/passwordstore/util/services/PasswordExportService.kt | 5 | ||||
-rw-r--r-- | crypto/pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandler.kt | 6 |
2 files changed, 8 insertions, 3 deletions
diff --git a/app/src/main/java/app/passwordstore/util/services/PasswordExportService.kt b/app/src/main/java/app/passwordstore/util/services/PasswordExportService.kt index c74c3f0e..854071f2 100644 --- a/app/src/main/java/app/passwordstore/util/services/PasswordExportService.kt +++ b/app/src/main/java/app/passwordstore/util/services/PasswordExportService.kt @@ -89,7 +89,10 @@ class PasswordExportService : Service() { val destOutputStream = contentResolver.openOutputStream(targetPasswordFile.uri) if (destOutputStream != null && sourceInputStream != null) { - sourceInputStream.use { source -> destOutputStream.use { dest -> source.copyTo(dest) } } + sourceInputStream.copyTo(destOutputStream, 1024) + + sourceInputStream.close() + destOutputStream.close() } } } diff --git a/crypto/pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandler.kt b/crypto/pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandler.kt index 4a800129..91826001 100644 --- a/crypto/pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandler.kt +++ b/crypto/pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandler.kt @@ -65,7 +65,8 @@ public class PGPainlessCryptoHandler @Inject constructor() : .addDecryptionKeys(keyringCollection, protector) .addDecryptionPassphrase(Passphrase.fromPassword(passphrase)) ) - decryptionStream.use { Streams.pipeAll(it, outputStream) } + Streams.pipeAll(decryptionStream, outputStream) + decryptionStream.close() return@runCatching } .mapError { error -> @@ -120,7 +121,8 @@ public class PGPainlessCryptoHandler @Inject constructor() : .setAsciiArmor(options.isOptionEnabled(PGPEncryptOptions.ASCII_ARMOR)) val encryptionStream = PGPainless.encryptAndOrSign().onOutputStream(outputStream).withOptions(producerOptions) - encryptionStream.use { Streams.pipeAll(plaintextStream, it) } + Streams.pipeAll(plaintextStream, encryptionStream) + encryptionStream.close() val result = encryptionStream.result publicKeyRingCollection.forEach { keyRing -> require(result.isEncryptedFor(keyRing)) { |