Revert "refactor: use Closeable#use extension where applicable"

This reverts commit 69513bf246.
This commit is contained in:
Harsh Shandilya 2024-09-26 17:49:58 +05:30
parent cb22561878
commit 04f4b9804f
2 changed files with 8 additions and 3 deletions

View file

@ -89,7 +89,10 @@ class PasswordExportService : Service() {
val destOutputStream = contentResolver.openOutputStream(targetPasswordFile.uri) val destOutputStream = contentResolver.openOutputStream(targetPasswordFile.uri)
if (destOutputStream != null && sourceInputStream != null) { if (destOutputStream != null && sourceInputStream != null) {
sourceInputStream.use { source -> destOutputStream.use { dest -> source.copyTo(dest) } } sourceInputStream.copyTo(destOutputStream, 1024)
sourceInputStream.close()
destOutputStream.close()
} }
} }
} }

View file

@ -65,7 +65,8 @@ public class PGPainlessCryptoHandler @Inject constructor() :
.addDecryptionKeys(keyringCollection, protector) .addDecryptionKeys(keyringCollection, protector)
.addDecryptionPassphrase(Passphrase.fromPassword(passphrase)) .addDecryptionPassphrase(Passphrase.fromPassword(passphrase))
) )
decryptionStream.use { Streams.pipeAll(it, outputStream) } Streams.pipeAll(decryptionStream, outputStream)
decryptionStream.close()
return@runCatching return@runCatching
} }
.mapError { error -> .mapError { error ->
@ -120,7 +121,8 @@ public class PGPainlessCryptoHandler @Inject constructor() :
.setAsciiArmor(options.isOptionEnabled(PGPEncryptOptions.ASCII_ARMOR)) .setAsciiArmor(options.isOptionEnabled(PGPEncryptOptions.ASCII_ARMOR))
val encryptionStream = val encryptionStream =
PGPainless.encryptAndOrSign().onOutputStream(outputStream).withOptions(producerOptions) PGPainless.encryptAndOrSign().onOutputStream(outputStream).withOptions(producerOptions)
encryptionStream.use { Streams.pipeAll(plaintextStream, it) } Streams.pipeAll(plaintextStream, encryptionStream)
encryptionStream.close()
val result = encryptionStream.result val result = encryptionStream.result
publicKeyRingCollection.forEach { keyRing -> publicKeyRingCollection.forEach { keyRing ->
require(result.isEncryptedFor(keyRing)) { require(result.isEncryptedFor(keyRing)) {