Browse Source

Changes from comments in PR #337

masensio 11 năm trước cách đây
mục cha
commit
685c26589b

+ 1 - 1
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);

+ 0 - 7
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();
                 }

+ 1 - 27
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.