Added cancelation for each synchronizeFolderOperation when canceling download folder

This commit is contained in:
jabarros 2014-12-16 14:28:36 +01:00
parent 0c8d508a61
commit f22693cd4e

View file

@ -27,6 +27,7 @@ import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileDownloader; import com.owncloud.android.files.services.FileDownloader;
import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.OperationCancelledException; import com.owncloud.android.lib.common.operations.OperationCancelledException;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.common.utils.Log_OC;
@ -145,6 +146,10 @@ public class SynchronizeFolderOperation extends SyncOperation {
synchronized(mCancellationRequested) { synchronized(mCancellationRequested) {
if (mCancellationRequested.get()) { if (mCancellationRequested.get()) {
// Cancel each operation in mFoldersToWalkDown
for (SyncOperation synchOp: mFoldersToWalkDown) {
((SynchronizeFolderOperation) synchOp).cancel();
}
return new RemoteOperationResult(new OperationCancelledException()); return new RemoteOperationResult(new OperationCancelledException());
} }
} }
@ -502,8 +507,6 @@ public class SynchronizeFolderOperation extends SyncOperation {
* Cancel operation * Cancel operation
*/ */
public void cancel(){ public void cancel(){
// WIP Cancel the sync operation
mCancellationRequested.set(true); mCancellationRequested.set(true);
} }
} }