This repository was archived by the owner on Oct 15, 2024. It is now read-only.
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
2 files changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -89,10 +89,7 @@ class PasswordExportService : Service() {
89
89
val destOutputStream = contentResolver.openOutputStream(targetPasswordFile.uri)
90
90
91
91
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) } }
96
93
}
97
94
}
98
95
}
Original file line number Diff line number Diff line change @@ -65,8 +65,7 @@ public class PGPainlessCryptoHandler @Inject constructor() :
65
65
.addDecryptionKeys(keyringCollection, protector)
66
66
.addDecryptionPassphrase(Passphrase .fromPassword(passphrase))
67
67
)
68
- Streams .pipeAll(decryptionStream, outputStream)
69
- decryptionStream.close()
68
+ decryptionStream.use { Streams .pipeAll(it, outputStream) }
70
69
return @runCatching
71
70
}
72
71
.mapError { error ->
@@ -121,8 +120,7 @@ public class PGPainlessCryptoHandler @Inject constructor() :
121
120
.setAsciiArmor(options.isOptionEnabled(PGPEncryptOptions .ASCII_ARMOR ))
122
121
val encryptionStream =
123
122
PGPainless .encryptAndOrSign().onOutputStream(outputStream).withOptions(producerOptions)
124
- Streams .pipeAll(plaintextStream, encryptionStream)
125
- encryptionStream.close()
123
+ encryptionStream.use { Streams .pipeAll(plaintextStream, it) }
126
124
val result = encryptionStream.result
127
125
publicKeyRingCollection.forEach { keyRing ->
128
126
require(result.isEncryptedFor(keyRing)) {
You can’t perform that action at this time.
0 commit comments