Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 37bae10

Browse files
authored
Merge pull request #436 from owncloud/fix/final_chunk_size
Fix a protocol exception when uploading chunked files
2 parents 1baeebe + 10e4462 commit 37bae10

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/ChunkFromFileRequestBody.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ public void writeTo(BufferedSink sink) {
8686

8787
readCount = mChannel.read(mBuffer);
8888

89-
sink.getBuffer().write(mBuffer.array(), 0, readCount);
89+
int bytesToWriteInBuffer = (int) Math.min(readCount, mFile.length() - mTransferred);
90+
sink.getBuffer().write(mBuffer.array(), 0, bytesToWriteInBuffer);
9091

9192
sink.flush();
9293

@@ -102,14 +103,12 @@ public void writeTo(BufferedSink sink) {
102103
}
103104
}
104105

105-
Timber.v("Chunk with size " + mChunkSize + " written in request body");
106-
107106
} catch (Exception exception) {
108-
Timber.e(exception);
107+
Timber.e(exception, "Transferred " + mTransferred + " bytes from a total of " + mFile.length());
109108
}
110109
}
111110

112111
public void setOffset(long offset) {
113112
this.mOffset = offset;
114113
}
115-
}
114+
}

0 commit comments

Comments
 (0)