Fixed behaviour when user enters in a folder deleted in the server before the app...
authorDavid A. Velasco <dvelasco@solidgear.es>
Wed, 2 Oct 2013 08:40:03 +0000 (10:40 +0200)
committerDavid A. Velasco <dvelasco@solidgear.es>
Wed, 2 Oct 2013 08:40:03 +0000 (10:40 +0200)
src/com/owncloud/android/operations/SynchronizeFolderOperation.java
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

index b15119a..a50bf95 100644 (file)
@@ -276,24 +276,25 @@ public class SynchronizeFolderOperation extends RemoteOperation {
                 } else {
                     client.exhaustResponse(query.getResponseBodyAsStream());
                 }
-            }
-
-            // prepare result object
-            if (!dirChanged) {
-                result = new RemoteOperationResult(ResultCode.OK_NO_CHANGES_ON_DIR);
-                mChildren = mStorageManager.getDirectoryContent(mStorageManager.getFileById(mParentId));
-
-            } else if (isMultiStatus(status)) {
-                if (mConflictsFound > 0  || mFailsInFavouritesFound > 0) { 
-                    result = new RemoteOperationResult(ResultCode.SYNC_CONFLICT);   // should be different result, but will do the job
+                
+                
+                // prepare result object
+                if (!dirChanged) {
+                    result = new RemoteOperationResult(ResultCode.OK_NO_CHANGES_ON_DIR);
+                    mChildren = mStorageManager.getDirectoryContent(mStorageManager.getFileById(mParentId));
 
                 } else {
-                    result = new RemoteOperationResult(true, status, query.getResponseHeaders());
+                    if (mConflictsFound > 0  || mFailsInFavouritesFound > 0) { 
+                        result = new RemoteOperationResult(ResultCode.SYNC_CONFLICT);   // should be different result, but will do the job
+
+                    } else {
+                        result = new RemoteOperationResult(true, status, query.getResponseHeaders());
+                    }
                 }
+                
             } else {
                 result = new RemoteOperationResult(false, status, query.getResponseHeaders());
             }
-            Log_OC.i(TAG, "Synchronizing " + mAccount.name + ", folder " + mRemotePath + ": " + result.getLogMessage());
 
         } catch (Exception e) {
             result = new RemoteOperationResult(e);
@@ -303,12 +304,12 @@ public class SynchronizeFolderOperation extends RemoteOperation {
             if (query != null)
                 query.releaseConnection();  // let the connection available for other methods
             if (result.isSuccess()) {
-                Log_OC.i(TAG, "Synchronizing " + mAccount.name + ", folder " + mRemotePath + ": " + result.getLogMessage());
+                Log_OC.i(TAG, "Synchroned " + mAccount.name + ", folder " + mRemotePath + ": " + result.getLogMessage());
             } else {
                 if (result.isException()) {
-                    Log_OC.e(TAG, "Synchronizing " + mAccount.name + ", folder " + mRemotePath + ": " + result.getLogMessage(), result.getException());
+                    Log_OC.e(TAG, "Synchroned " + mAccount.name + ", folder " + mRemotePath + ": " + result.getLogMessage(), result.getException());
                 } else {
-                    Log_OC.e(TAG, "Synchronizing " + mAccount.name + ", folder " + mRemotePath + ": " + result.getLogMessage());
+                    Log_OC.e(TAG, "Synchroned " + mAccount.name + ", folder " + mRemotePath + ": " + result.getLogMessage());
                 }
             }
             
index bacc6a9..f886732 100644 (file)
@@ -880,15 +880,19 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
 
                 if ((synchFolderRemotePath != null && currentDir != null && (currentDir.getRemotePath().equals(synchFolderRemotePath)))
                         || fillBlankRoot ) {
-                    if (!fillBlankRoot) 
-                        currentDir = getStorageManager().getFileByPath(synchFolderRemotePath);
-                    OCFileListFragment fileListFragment = getListOfFilesFragment();
-                    if (fileListFragment != null) {
-                        fileListFragment.listDirectory(currentDir);
-                        
+                    if (synchResult == null || synchResult.isSuccess()) {
+                        if (!fillBlankRoot) 
+                            currentDir = getStorageManager().getFileByPath(synchFolderRemotePath);
+                        if (currentDir != null) {
+                            OCFileListFragment fileListFragment = getListOfFilesFragment();
+                            if (fileListFragment != null) {
+                                fileListFragment.listDirectory(currentDir);
+                                
+                            }
+                            if (getSecondFragment() == null)
+                                setFile(currentDir);
+                        }
                     }
-                    if (getSecondFragment() == null)
-                        setFile(currentDir);
                 }
                 
                 setSupportProgressBarIndeterminateVisibility(inProgress);