diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2024-09-22 23:45:14 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2024-09-22 23:51:55 +0530 |
commit | 69513bf24613d4ba540bcdeaffe04dc9330a65a4 (patch) | |
tree | 3652a618095ab1581cd3a28ea415b15f0c48d4ca /crypto/pgpainless/src/main/kotlin/app | |
parent | 6a5e35a95c795e7c56048ac36d86da53c2799e4e (diff) |
refactor: use `Closeable#use` extension where applicable
Diffstat (limited to 'crypto/pgpainless/src/main/kotlin/app')
-rw-r--r-- | crypto/pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandler.kt | 6 |
1 files changed, 2 insertions, 4 deletions
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)) { |