diff --git a/src/org/thoughtcrime/securesms/crypto/DecryptingPartInputStream.java b/src/org/thoughtcrime/securesms/crypto/DecryptingPartInputStream.java index 33037c0b63..56ca56d7c3 100644 --- a/src/org/thoughtcrime/securesms/crypto/DecryptingPartInputStream.java +++ b/src/org/thoughtcrime/securesms/crypto/DecryptingPartInputStream.java @@ -19,6 +19,7 @@ package org.thoughtcrime.securesms.crypto; import android.util.Log; import org.thoughtcrime.securesms.util.LimitedInputStream; +import org.thoughtcrime.securesms.util.Util; import java.io.File; import java.io.FileInputStream; @@ -139,5 +140,30 @@ public class DecryptingPartInputStream { Log.w(TAG, t); } } + + @Override + public long skip(long skipAmount) + throws IOException + { + long remaining = skipAmount; + + if (skipAmount <= 0) { + return 0; + } + + byte[] skipBuffer = new byte[4092]; + + while (remaining > 0) { + int read = super.read(skipBuffer, 0, Util.toIntExact(Math.min(skipBuffer.length, remaining))); + + if (read < 0) { + break; + } + + remaining -= read; + } + + return skipAmount - remaining; + } } }