From 5803f0244a5669b10f09b3f75fe3493143f0aff3 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sat, 28 Sep 2024 23:35:54 +0530 Subject: Reapply "refactor: use `Closeable#use` extension where applicable" This reverts commit 04f4b9804f10e4724bac22d40bf01711ff708533. --- .../main/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandler.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'crypto/pgpainless/src') 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 91826001..4a800129 100644 --- a/crypto/pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandler.kt +++ b/crypto/pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandler.kt @@ -65,8 +65,7 @@ public class PGPainlessCryptoHandler @Inject constructor() : .addDecryptionKeys(keyringCollection, protector) .addDecryptionPassphrase(Passphrase.fromPassword(passphrase)) ) - Streams.pipeAll(decryptionStream, outputStream) - decryptionStream.close() + decryptionStream.use { Streams.pipeAll(it, outputStream) } return@runCatching } .mapError { error -> @@ -121,8 +120,7 @@ public class PGPainlessCryptoHandler @Inject constructor() : .setAsciiArmor(options.isOptionEnabled(PGPEncryptOptions.ASCII_ARMOR)) val encryptionStream = PGPainless.encryptAndOrSign().onOutputStream(outputStream).withOptions(producerOptions) - Streams.pipeAll(plaintextStream, encryptionStream) - encryptionStream.close() + encryptionStream.use { Streams.pipeAll(plaintextStream, it) } val result = encryptionStream.result publicKeyRingCollection.forEach { keyRing -> require(result.isEncryptedFor(keyRing)) { -- cgit v1.2.3