mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-12-05 11:51:09 +01:00
SOP armor: catch IOException during inspection of data
This commit is contained in:
parent
b10e117795
commit
a3d45c0455
1 changed files with 9 additions and 2 deletions
|
|
@ -15,6 +15,7 @@ import org.pgpainless.util.ArmoredOutputStreamFactory
|
||||||
import sop.Ready
|
import sop.Ready
|
||||||
import sop.exception.SOPGPException
|
import sop.exception.SOPGPException
|
||||||
import sop.operation.Armor
|
import sop.operation.Armor
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
/** Implementation of the `armor` operation using PGPainless. */
|
/** Implementation of the `armor` operation using PGPainless. */
|
||||||
class ArmorImpl(private val api: PGPainless) : Armor {
|
class ArmorImpl(private val api: PGPainless) : Armor {
|
||||||
|
|
@ -27,8 +28,14 @@ class ArmorImpl(private val api: PGPainless) : Armor {
|
||||||
val bufferedOutputStream = BufferedOutputStream(outputStream)
|
val bufferedOutputStream = BufferedOutputStream(outputStream)
|
||||||
|
|
||||||
// Determine the nature of the given data
|
// Determine the nature of the given data
|
||||||
val openPgpIn = OpenPGPAnimalSnifferInputStream(data)
|
val openPgpIn = OpenPGPAnimalSnifferInputStream(data).apply {
|
||||||
openPgpIn.reset()
|
try {
|
||||||
|
inspectBuffer()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
reset()
|
||||||
|
}
|
||||||
|
|
||||||
if (openPgpIn.isAsciiArmored) {
|
if (openPgpIn.isAsciiArmored) {
|
||||||
// armoring already-armored data is an idempotent operation
|
// armoring already-armored data is an idempotent operation
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue