Loading app/core/src/main/java/com/fsck/k9/controller/ProgressBodyFactory.java +1 −3 Original line number Diff line number Diff line Loading @@ -21,10 +21,8 @@ class ProgressBodyFactory extends DefaultBodyFactory { @Override protected void copyData(InputStream inputStream, OutputStream outputStream) throws IOException { final CountingOutputStream countingOutputStream = new CountingOutputStream(outputStream); Timer timer = new Timer(); try { try (CountingOutputStream countingOutputStream = new CountingOutputStream(outputStream)) { timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { Loading app/core/src/main/java/com/fsck/k9/mailstore/LocalFolder.java +6 −11 Original line number Diff line number Diff line Loading @@ -785,21 +785,16 @@ public class LocalFolder { } private long decodeAndCountBytes(InputStream rawInputStream, String encoding, long fallbackValue) { InputStream decodingInputStream = localStore.getDecodingInputStream(rawInputStream, encoding); try { CountingOutputStream countingOutputStream = new CountingOutputStream(); try { IOUtils.copy(decodingInputStream, countingOutputStream); try (InputStream decodingInputStream = localStore.getDecodingInputStream(rawInputStream, encoding)) { try (CountingOutputStream countingOutputStream = new CountingOutputStream()) { IOUtils.copy(decodingInputStream, countingOutputStream); return countingOutputStream.getCount(); } } catch (IOException e) { return fallbackValue; } } finally { try { decodingInputStream.close(); } catch (IOException e) { /* ignore */ } } } private byte[] getHeaderBytes(Part part) throws IOException, MessagingException { Loading app/core/src/main/java/com/fsck/k9/provider/RawMessageProvider.java +1 −2 Original line number Diff line number Diff line Loading @@ -99,8 +99,7 @@ public class RawMessageProvider extends ContentProvider { private long computeMessageSize(LocalMessage message) { // TODO: Store message size in database when saving message so this can be a simple lookup instead. try { CountingOutputStream countingOutputStream = new CountingOutputStream(); try (CountingOutputStream countingOutputStream = new CountingOutputStream()) { message.writeTo(countingOutputStream); return countingOutputStream.getCount(); } catch (IOException | MessagingException e) { Loading app/storage/src/main/java/com/fsck/k9/storage/messages/SaveMessageOperations.kt +4 −3 Original line number Diff line number Diff line Loading @@ -305,10 +305,11 @@ internal class SaveMessageOperations( private fun decodeAndCountBytes(rawInputStream: InputStream, encoding: String, fallbackValue: Long): Long { return try { getDecodingInputStream(rawInputStream, encoding).use { decodingInputStream -> val countingOutputStream = CountingOutputStream() CountingOutputStream().use { countingOutputStream -> IOUtils.copy(decodingInputStream, countingOutputStream) countingOutputStream.count } } } catch (e: IOException) { fallbackValue } Loading mail/common/src/main/java/com/fsck/k9/mail/Message.java +2 −6 Original line number Diff line number Diff line Loading @@ -159,16 +159,12 @@ public abstract class Message implements Part, Body { public abstract void setEncoding(String encoding) throws MessagingException; public long calculateSize() { try { CountingOutputStream out = new CountingOutputStream(); try (CountingOutputStream out = new CountingOutputStream()) { EOLConvertingOutputStream eolOut = new EOLConvertingOutputStream(out); writeTo(eolOut); eolOut.flush(); return out.getCount(); } catch (IOException e) { Timber.e(e, "Failed to calculate a message size"); } catch (MessagingException e) { } catch (IOException | MessagingException e) { Timber.e(e, "Failed to calculate a message size"); } return 0; Loading Loading
app/core/src/main/java/com/fsck/k9/controller/ProgressBodyFactory.java +1 −3 Original line number Diff line number Diff line Loading @@ -21,10 +21,8 @@ class ProgressBodyFactory extends DefaultBodyFactory { @Override protected void copyData(InputStream inputStream, OutputStream outputStream) throws IOException { final CountingOutputStream countingOutputStream = new CountingOutputStream(outputStream); Timer timer = new Timer(); try { try (CountingOutputStream countingOutputStream = new CountingOutputStream(outputStream)) { timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { Loading
app/core/src/main/java/com/fsck/k9/mailstore/LocalFolder.java +6 −11 Original line number Diff line number Diff line Loading @@ -785,21 +785,16 @@ public class LocalFolder { } private long decodeAndCountBytes(InputStream rawInputStream, String encoding, long fallbackValue) { InputStream decodingInputStream = localStore.getDecodingInputStream(rawInputStream, encoding); try { CountingOutputStream countingOutputStream = new CountingOutputStream(); try { IOUtils.copy(decodingInputStream, countingOutputStream); try (InputStream decodingInputStream = localStore.getDecodingInputStream(rawInputStream, encoding)) { try (CountingOutputStream countingOutputStream = new CountingOutputStream()) { IOUtils.copy(decodingInputStream, countingOutputStream); return countingOutputStream.getCount(); } } catch (IOException e) { return fallbackValue; } } finally { try { decodingInputStream.close(); } catch (IOException e) { /* ignore */ } } } private byte[] getHeaderBytes(Part part) throws IOException, MessagingException { Loading
app/core/src/main/java/com/fsck/k9/provider/RawMessageProvider.java +1 −2 Original line number Diff line number Diff line Loading @@ -99,8 +99,7 @@ public class RawMessageProvider extends ContentProvider { private long computeMessageSize(LocalMessage message) { // TODO: Store message size in database when saving message so this can be a simple lookup instead. try { CountingOutputStream countingOutputStream = new CountingOutputStream(); try (CountingOutputStream countingOutputStream = new CountingOutputStream()) { message.writeTo(countingOutputStream); return countingOutputStream.getCount(); } catch (IOException | MessagingException e) { Loading
app/storage/src/main/java/com/fsck/k9/storage/messages/SaveMessageOperations.kt +4 −3 Original line number Diff line number Diff line Loading @@ -305,10 +305,11 @@ internal class SaveMessageOperations( private fun decodeAndCountBytes(rawInputStream: InputStream, encoding: String, fallbackValue: Long): Long { return try { getDecodingInputStream(rawInputStream, encoding).use { decodingInputStream -> val countingOutputStream = CountingOutputStream() CountingOutputStream().use { countingOutputStream -> IOUtils.copy(decodingInputStream, countingOutputStream) countingOutputStream.count } } } catch (e: IOException) { fallbackValue } Loading
mail/common/src/main/java/com/fsck/k9/mail/Message.java +2 −6 Original line number Diff line number Diff line Loading @@ -159,16 +159,12 @@ public abstract class Message implements Part, Body { public abstract void setEncoding(String encoding) throws MessagingException; public long calculateSize() { try { CountingOutputStream out = new CountingOutputStream(); try (CountingOutputStream out = new CountingOutputStream()) { EOLConvertingOutputStream eolOut = new EOLConvertingOutputStream(out); writeTo(eolOut); eolOut.flush(); return out.getCount(); } catch (IOException e) { Timber.e(e, "Failed to calculate a message size"); } catch (MessagingException e) { } catch (IOException | MessagingException e) { Timber.e(e, "Failed to calculate a message size"); } return 0; Loading