This repository was archived by the owner on Oct 15, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +3
-8
lines changed
app/src/main/java/app/passwordstore/util/services
crypto/pgpainless/src/main/kotlin/app/passwordstore/crypto Expand file tree Collapse file tree 2 files changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -89,10 +89,7 @@ class PasswordExportService : Service() {
8989 val destOutputStream = contentResolver.openOutputStream(targetPasswordFile.uri)
9090
9191 if (destOutputStream != null && sourceInputStream != null ) {
92- sourceInputStream.copyTo(destOutputStream, 1024 )
93-
94- sourceInputStream.close()
95- destOutputStream.close()
92+ sourceInputStream.use { source -> destOutputStream.use { dest -> source.copyTo(dest) } }
9693 }
9794 }
9895 }
Original file line number Diff line number Diff line change @@ -65,8 +65,7 @@ public class PGPainlessCryptoHandler @Inject constructor() :
6565 .addDecryptionKeys(keyringCollection, protector)
6666 .addDecryptionPassphrase(Passphrase .fromPassword(passphrase))
6767 )
68- Streams .pipeAll(decryptionStream, outputStream)
69- decryptionStream.close()
68+ decryptionStream.use { Streams .pipeAll(it, outputStream) }
7069 return @runCatching
7170 }
7271 .mapError { error ->
@@ -121,8 +120,7 @@ public class PGPainlessCryptoHandler @Inject constructor() :
121120 .setAsciiArmor(options.isOptionEnabled(PGPEncryptOptions .ASCII_ARMOR ))
122121 val encryptionStream =
123122 PGPainless .encryptAndOrSign().onOutputStream(outputStream).withOptions(producerOptions)
124- Streams .pipeAll(plaintextStream, encryptionStream)
125- encryptionStream.close()
123+ encryptionStream.use { Streams .pipeAll(plaintextStream, it) }
126124 val result = encryptionStream.result
127125 publicKeyRingCollection.forEach { keyRing ->
128126 require(result.isEncryptedFor(keyRing)) {
You can’t perform that action at this time.
0 commit comments