From 3a82dfb23f1e63f36ce7d7357e7fb25e29985e77 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Sat, 20 Feb 2016 12:34:14 +0100 Subject: [PATCH] - fixed return value of readBlockAligend - adjusted loglevel of BlockAlignedWritableFile [ci skip] --- .../blockaligned/BlockAlignedReadableFile.java | 14 +++++++++----- .../blockaligned/BlockAlignedWritableFile.java | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/blockaligned/BlockAlignedReadableFile.java b/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/blockaligned/BlockAlignedReadableFile.java index 3267f89b7..289a13132 100644 --- a/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/blockaligned/BlockAlignedReadableFile.java +++ b/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/blockaligned/BlockAlignedReadableFile.java @@ -69,12 +69,16 @@ class BlockAlignedReadableFile implements ReadableFile { } private int readBlockAligned(ByteBuffer target) { - int read = -1; - while (!eofReached && target.hasRemaining()) { - read += ByteBuffers.copy(currentBlockBuffer, target); - readCurrentBlockIfNeeded(); + if (eofReached) { + return -1; + } else { + int read = 0; + while (!eofReached && target.hasRemaining()) { + read += ByteBuffers.copy(currentBlockBuffer, target); + readCurrentBlockIfNeeded(); + } + return read; } - return read; } private void readCurrentBlockIfNeeded() { diff --git a/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/blockaligned/BlockAlignedWritableFile.java b/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/blockaligned/BlockAlignedWritableFile.java index a79285f8c..7df2c6257 100644 --- a/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/blockaligned/BlockAlignedWritableFile.java +++ b/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/blockaligned/BlockAlignedWritableFile.java @@ -54,7 +54,7 @@ class BlockAlignedWritableFile implements WritableFile { // visible for testing void switchToBlockAlignedMode() { - LOG.debug("switching to blockaligend write..."); + LOG.trace("switching to blockaligend write..."); mode = Mode.BLOCK_ALIGNED; }