From ed073d6db0924d5f289092139b3198e01cfffe7a Mon Sep 17 00:00:00 2001 From: davigonz Date: Mon, 2 Jul 2018 10:08:12 +0200 Subject: [PATCH] Add timeout to last chunk --- .../files/ChunkedUploadRemoteFileOperation.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/com/owncloud/android/lib/resources/files/ChunkedUploadRemoteFileOperation.java b/src/com/owncloud/android/lib/resources/files/ChunkedUploadRemoteFileOperation.java index 7b12df8a..1fc402bd 100644 --- a/src/com/owncloud/android/lib/resources/files/ChunkedUploadRemoteFileOperation.java +++ b/src/com/owncloud/android/lib/resources/files/ChunkedUploadRemoteFileOperation.java @@ -35,6 +35,7 @@ import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.channels.FileChannel; +import java.util.concurrent.TimeUnit; import okhttp3.MediaType; @@ -118,12 +119,12 @@ public class ChunkedUploadRemoteFileOperation extends UploadRemoteFileOperation // // next method will throw an exception // } -// if (chunkIndex == chunkCount - 1) { -// // Added a high timeout to the last chunk due to when the last chunk -// // arrives to the server with the last PUT, all chunks get assembled -// // within that PHP request, so last one takes longer. -// mPutMethod.getParams().setSoTimeout(LAST_CHUNK_TIMEOUT); -// } + if (chunkIndex == chunkCount - 1) { + // Added a high timeout to the last chunk due to when the last chunk + // arrives to the server with the last PUT, all chunks get assembled + // within that PHP request, so last one takes longer. + mPutMethod.setReadTimeout(LAST_CHUNK_TIMEOUT, TimeUnit.MILLISECONDS); + } mPutMethod.setRequestBody(mFileRequestBody);