Loading src/com/owncloud/android/lib/resources/files/ChunkedUploadRemoteFileOperation.java +4 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,6 @@ import java.io.RandomAccessFile; import java.nio.channels.FileChannel; import java.util.Random; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.methods.PutMethod; import com.owncloud.android.lib.common.OwnCloudClient; Loading Loading @@ -85,6 +84,10 @@ public class ChunkedUploadRemoteFileOperation extends UploadRemoteFileOperation mPutMethod.addRequestHeader(OC_TOTAL_LENGTH_HEADER, String.valueOf(file.length())); ((ChunkFromFileChannelRequestEntity) mEntity).setOffset(offset); mPutMethod.setRequestEntity(mEntity); if (mCancellationRequested.get()) { mPutMethod.abort(); // next method will throw an exception } status = client.executeMethod(mPutMethod); if (status == 400) { Loading src/com/owncloud/android/lib/resources/files/UploadRemoteFileOperation.java +17 −16 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ public class UploadRemoteFileOperation extends RemoteOperation { protected PutMethod mPutMethod = null; protected boolean mForbiddenCharsInServer = false; private final AtomicBoolean mCancellationRequested = new AtomicBoolean(false); protected final AtomicBoolean mCancellationRequested = new AtomicBoolean(false); protected Set<OnDatatransferProgressListener> mDataTransferListeners = new HashSet<OnDatatransferProgressListener>(); protected RequestEntity mEntity = null; Loading @@ -83,16 +83,14 @@ public class UploadRemoteFileOperation extends RemoteOperation { RemoteOperationResult result = null; try { // / perform the upload synchronized (mCancellationRequested) { mPutMethod = new PutMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath)); if (mCancellationRequested.get()) { throw new OperationCancelledException(); } else { mPutMethod = new PutMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath)); } } // the operation was cancelled before getting it's turn to be executed in the queue of uploads result = new RemoteOperationResult(new OperationCancelledException()); } else { // perform the upload int status = uploadFile(client); if (mForbiddenCharsInServer){ result = new RemoteOperationResult( Loading @@ -101,9 +99,12 @@ public class UploadRemoteFileOperation extends RemoteOperation { result = new RemoteOperationResult(isSuccess(status), status, (mPutMethod != null ? mPutMethod.getResponseHeaders() : null)); } } } catch (Exception e) { if (mCancellationRequested.get() && !(e instanceof OperationCancelledException)) { if (mPutMethod != null && mPutMethod.isAborted()) { result = new RemoteOperationResult(new OperationCancelledException()); } else { result = new RemoteOperationResult(e); } Loading Loading
src/com/owncloud/android/lib/resources/files/ChunkedUploadRemoteFileOperation.java +4 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,6 @@ import java.io.RandomAccessFile; import java.nio.channels.FileChannel; import java.util.Random; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.methods.PutMethod; import com.owncloud.android.lib.common.OwnCloudClient; Loading Loading @@ -85,6 +84,10 @@ public class ChunkedUploadRemoteFileOperation extends UploadRemoteFileOperation mPutMethod.addRequestHeader(OC_TOTAL_LENGTH_HEADER, String.valueOf(file.length())); ((ChunkFromFileChannelRequestEntity) mEntity).setOffset(offset); mPutMethod.setRequestEntity(mEntity); if (mCancellationRequested.get()) { mPutMethod.abort(); // next method will throw an exception } status = client.executeMethod(mPutMethod); if (status == 400) { Loading
src/com/owncloud/android/lib/resources/files/UploadRemoteFileOperation.java +17 −16 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ public class UploadRemoteFileOperation extends RemoteOperation { protected PutMethod mPutMethod = null; protected boolean mForbiddenCharsInServer = false; private final AtomicBoolean mCancellationRequested = new AtomicBoolean(false); protected final AtomicBoolean mCancellationRequested = new AtomicBoolean(false); protected Set<OnDatatransferProgressListener> mDataTransferListeners = new HashSet<OnDatatransferProgressListener>(); protected RequestEntity mEntity = null; Loading @@ -83,16 +83,14 @@ public class UploadRemoteFileOperation extends RemoteOperation { RemoteOperationResult result = null; try { // / perform the upload synchronized (mCancellationRequested) { mPutMethod = new PutMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath)); if (mCancellationRequested.get()) { throw new OperationCancelledException(); } else { mPutMethod = new PutMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath)); } } // the operation was cancelled before getting it's turn to be executed in the queue of uploads result = new RemoteOperationResult(new OperationCancelledException()); } else { // perform the upload int status = uploadFile(client); if (mForbiddenCharsInServer){ result = new RemoteOperationResult( Loading @@ -101,9 +99,12 @@ public class UploadRemoteFileOperation extends RemoteOperation { result = new RemoteOperationResult(isSuccess(status), status, (mPutMethod != null ? mPutMethod.getResponseHeaders() : null)); } } } catch (Exception e) { if (mCancellationRequested.get() && !(e instanceof OperationCancelledException)) { if (mPutMethod != null && mPutMethod.isAborted()) { result = new RemoteOperationResult(new OperationCancelledException()); } else { result = new RemoteOperationResult(e); } Loading