Bug fixed: Upload fails
[pub/Android/ownCloud.git] / src / com / owncloud / android / operations / SynchronizeFolderOperation.java
index 61375c4..06760e8 100644 (file)
@@ -344,10 +344,11 @@ public class SynchronizeFolderOperation extends SyncOperation {
             /// classify file to sync/download contents later
             if (remoteFile.isFolder()) {
                 /// to download children files recursively
-                startSyncFolderOperation(remoteFile.getRemotePath());
-
-                if (mCancellationRequested.get()) {
-                    throw new OperationCancelledException();
+                synchronized(mCancellationRequested) {
+                    if (mCancellationRequested.get()) {
+                        throw new OperationCancelledException();
+                    }
+                    startSyncFolderOperation(remoteFile.getRemotePath());
                 }
 
             } else if (remoteFile.keepInSync()) {
@@ -389,9 +390,11 @@ public class SynchronizeFolderOperation extends SyncOperation {
             /// classify file to sync/download contents later
             if (child.isFolder()) {
                 /// to download children files recursively
-                startSyncFolderOperation(child.getRemotePath());
-                if (mCancellationRequested.get()) {
-                    throw new OperationCancelledException();
+                synchronized(mCancellationRequested) {
+                    if (mCancellationRequested.get()) {
+                        throw new OperationCancelledException();
+                    }
+                    startSyncFolderOperation(child.getRemotePath());
                 }
 
             } else {
@@ -413,13 +416,15 @@ public class SynchronizeFolderOperation extends SyncOperation {
     
     private void startDirectDownloads() throws OperationCancelledException {
         for (OCFile file : mFilesForDirectDownload) {
-            if (mCancellationRequested.get()) {
-                throw new OperationCancelledException();
+            synchronized(mCancellationRequested) {
+                if (mCancellationRequested.get()) {
+                    throw new OperationCancelledException();
+                }
+                Intent i = new Intent(mContext, FileDownloader.class);
+                i.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);
+                i.putExtra(FileDownloader.EXTRA_FILE, file);
+                mContext.startService(i);
             }
-            Intent i = new Intent(mContext, FileDownloader.class);
-            i.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);
-            i.putExtra(FileDownloader.EXTRA_FILE, file);
-            mContext.startService(i);
         }
     }
 
@@ -435,7 +440,8 @@ public class SynchronizeFolderOperation extends SyncOperation {
      */
     private void startContentSynchronizations(List<SyncOperation> filesToSyncContents, OwnCloudClient client) 
             throws OperationCancelledException {
-        
+
+        Log_OC.v(TAG, "Starting content synchronization... ");
         RemoteOperationResult contentsResult = null;
         for (SyncOperation op: filesToSyncContents) {
             if (mCancellationRequested.get()) {
@@ -520,4 +526,8 @@ public class SynchronizeFolderOperation extends SyncOperation {
         intent.putExtra(OperationsService.EXTRA_REMOTE_PATH, path);
         mContext.startService(intent);
     }
+
+    public String getRemotePath() {
+        return mRemotePath;
+    }
 }