Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 04f4b98

Browse files
committed
Revert "refactor: use Closeable#use extension where applicable"
This reverts commit 69513bf.
1 parent cb22561 commit 04f4b98

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

app/src/main/java/app/passwordstore/util/services/PasswordExportService.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ class PasswordExportService : Service() {
8989
val destOutputStream = contentResolver.openOutputStream(targetPasswordFile.uri)
9090

9191
if (destOutputStream != null && sourceInputStream != null) {
92-
sourceInputStream.use { source -> destOutputStream.use { dest -> source.copyTo(dest) } }
92+
sourceInputStream.copyTo(destOutputStream, 1024)
93+
94+
sourceInputStream.close()
95+
destOutputStream.close()
9396
}
9497
}
9598
}

crypto/pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandler.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public class PGPainlessCryptoHandler @Inject constructor() :
6565
.addDecryptionKeys(keyringCollection, protector)
6666
.addDecryptionPassphrase(Passphrase.fromPassword(passphrase))
6767
)
68-
decryptionStream.use { Streams.pipeAll(it, outputStream) }
68+
Streams.pipeAll(decryptionStream, outputStream)
69+
decryptionStream.close()
6970
return@runCatching
7071
}
7172
.mapError { error ->
@@ -120,7 +121,8 @@ public class PGPainlessCryptoHandler @Inject constructor() :
120121
.setAsciiArmor(options.isOptionEnabled(PGPEncryptOptions.ASCII_ARMOR))
121122
val encryptionStream =
122123
PGPainless.encryptAndOrSign().onOutputStream(outputStream).withOptions(producerOptions)
123-
encryptionStream.use { Streams.pipeAll(plaintextStream, it) }
124+
Streams.pipeAll(plaintextStream, encryptionStream)
125+
encryptionStream.close()
124126
val result = encryptionStream.result
125127
publicKeyRingCollection.forEach { keyRing ->
126128
require(result.isEncryptedFor(keyRing)) {

0 commit comments

Comments
 (0)