From: masensio Date: Thu, 19 Dec 2013 08:24:28 +0000 (+0100) Subject: Changes from comments in PR #337 X-Git-Tag: oc-android-1.5.5~98 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/685c26589bb47cb68453bfd80c17a1d702fb2d99?ds=inline Changes from comments in PR #337 --- diff --git a/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java b/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java index 11f74cf2..2030a8f2 100644 --- a/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java +++ b/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java @@ -160,7 +160,7 @@ public class TestActivity extends Activity { public RemoteOperationResult uploadFile(String storagePath, String remotePath, String mimeType) { UploadRemoteFileOperation uploadOperation; - if (mChunked) { + if ( mChunked && (new File(storagePath)).length() > ChunkedUploadRemoteFileOperation.CHUNK_SIZE ) { uploadOperation = new ChunkedUploadRemoteFileOperation(storagePath, remotePath, mimeType); } else { uploadOperation = new UploadRemoteFileOperation(storagePath, remotePath, mimeType); diff --git a/src/com/owncloud/android/files/services/FileUploader.java b/src/com/owncloud/android/files/services/FileUploader.java index f38da6dc..00441946 100644 --- a/src/com/owncloud/android/files/services/FileUploader.java +++ b/src/com/owncloud/android/files/services/FileUploader.java @@ -267,13 +267,6 @@ public class FileUploader extends Service implements OnDatatransferProgressListe uploadKey = buildRemoteName(account, files[i].getRemotePath()); newUpload = new UploadFileOperation(account, files[i], chunked, isInstant, forceOverwrite, localAction, getApplicationContext()); -// if (chunked) { -// newUpload = new ChunkedUploadFileOperation(account, files[i], isInstant, forceOverwrite, -// localAction, getApplicationContext()); -// } else { -// newUpload = new UploadFileOperation(account, files[i], isInstant, forceOverwrite, localAction, -// getApplicationContext()); -// } if (isInstant) { newUpload.setRemoteFolderToBeCreated(); } diff --git a/src/com/owncloud/android/operations/UploadFileOperation.java b/src/com/owncloud/android/operations/UploadFileOperation.java index b0b9466f..9ceb9751 100644 --- a/src/com/owncloud/android/operations/UploadFileOperation.java +++ b/src/com/owncloud/android/operations/UploadFileOperation.java @@ -28,15 +28,12 @@ import java.util.Iterator; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.methods.PutMethod; import org.apache.commons.httpclient.methods.RequestEntity; -import org.apache.http.HttpStatus; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.files.services.FileUploader; import com.owncloud.android.oc_framework.network.ProgressiveDataTransferer; -import com.owncloud.android.oc_framework.network.webdav.FileRequestEntity; import com.owncloud.android.oc_framework.network.webdav.OnDatatransferProgressListener; import com.owncloud.android.oc_framework.network.webdav.WebdavClient; import com.owncloud.android.oc_framework.operations.OperationCancelledException; @@ -273,7 +270,7 @@ public class UploadFileOperation extends RemoteOperation { localCopyPassed = true; /// perform the upload - if (mChunked) { + if ( mChunked && (new File(mFile.getStoragePath())).length() > ChunkedUploadRemoteFileOperation.CHUNK_SIZE ) { mUploadOperation = new ChunkedUploadRemoteFileOperation(mFile.getStoragePath(), mFile.getRemotePath(), mFile.getMimetype()); } else { @@ -372,29 +369,6 @@ public class UploadFileOperation extends RemoteOperation { mFile = newFile; } -// public boolean isSuccess(int status) { -// return ((status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED || status == HttpStatus.SC_NO_CONTENT)); -// } -// -// protected int uploadFile(WebdavClient client) throws HttpException, IOException, OperationCancelledException { -// int status = -1; -// try { -// File f = new File(mFile.getStoragePath()); -// mEntity = new FileRequestEntity(f, getMimeType()); -// synchronized (mDataTransferListeners) { -// ((ProgressiveDataTransferer)mEntity).addDatatransferProgressListeners(mDataTransferListeners); -// } -// mPutMethod.setRequestEntity(mEntity); -// status = client.executeMethod(mPutMethod); -// client.exhaustResponse(mPutMethod.getResponseBodyAsStream()); -// -// } finally { -// mPutMethod.releaseConnection(); // let the connection available for -// // other methods -// } -// return status; -// } - /** * Checks if remotePath does not exist in the server and returns it, or adds * a suffix to it in order to avoid the server file is overwritten.