Skip attachments with unrecoverable errors during sms export.

This commit is contained in:
Cody Henthorne
2023-02-28 10:58:23 -05:00
committed by Greyson Parrelli
parent 57e8684bb3
commit 10e8c6d795
3 changed files with 23 additions and 4 deletions

View File

@@ -22,6 +22,8 @@ import javax.crypto.spec.SecretKeySpec;
public class ModernDecryptingPartInputStream {
public static final String PREMATURE_END_ERROR_MESSAGE = "Prematurely reached end of stream!";
public static InputStream createFor(@NonNull AttachmentSecret attachmentSecret, @NonNull byte[] random, @NonNull File file, long offset)
throws IOException
{
@@ -75,7 +77,7 @@ public class ModernDecryptingPartInputStream {
for (;;) {
int read = in.read(buffer, offset, buffer.length-offset);
if (read == -1) throw new IOException("Prematurely reached end of stream!");
if (read == -1) throw new IOException(PREMATURE_END_ERROR_MESSAGE);
else if (read + offset < buffer.length) offset += read;
else return;
}