mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-22 18:07:19 +00:00
Reapply "refactor: use Closeable#use
extension where applicable"
This reverts commit 04f4b9804f10e4724bac22d40bf01711ff708533.
This commit is contained in:
parent
7e1ed55ab7
commit
5803f0244a
@ -89,10 +89,7 @@ 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.copyTo(destOutputStream, 1024)
|
sourceInputStream.use { source -> destOutputStream.use { dest -> source.copyTo(dest) } }
|
||||||
|
|
||||||
sourceInputStream.close()
|
|
||||||
destOutputStream.close()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,8 +65,7 @@ public class PGPainlessCryptoHandler @Inject constructor() :
|
|||||||
.addDecryptionKeys(keyringCollection, protector)
|
.addDecryptionKeys(keyringCollection, protector)
|
||||||
.addDecryptionPassphrase(Passphrase.fromPassword(passphrase))
|
.addDecryptionPassphrase(Passphrase.fromPassword(passphrase))
|
||||||
)
|
)
|
||||||
Streams.pipeAll(decryptionStream, outputStream)
|
decryptionStream.use { Streams.pipeAll(it, outputStream) }
|
||||||
decryptionStream.close()
|
|
||||||
return@runCatching
|
return@runCatching
|
||||||
}
|
}
|
||||||
.mapError { error ->
|
.mapError { error ->
|
||||||
@ -121,8 +120,7 @@ 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)
|
||||||
Streams.pipeAll(plaintextStream, encryptionStream)
|
encryptionStream.use { Streams.pipeAll(plaintextStream, it) }
|
||||||
encryptionStream.close()
|
|
||||||
val result = encryptionStream.result
|
val result = encryptionStream.result
|
||||||
publicKeyRingCollection.forEach { keyRing ->
|
publicKeyRingCollection.forEach { keyRing ->
|
||||||
require(result.isEncryptedFor(keyRing)) {
|
require(result.isEncryptedFor(keyRing)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user