Trigger synchronization of current folder when the app is started or the current...
authorDavid A. Velasco <dvelasco@solidgear.es>
Mon, 21 Oct 2013 11:27:33 +0000 (13:27 +0200)
committerDavid A. Velasco <dvelasco@solidgear.es>
Mon, 21 Oct 2013 11:27:33 +0000 (13:27 +0200)
src/com/owncloud/android/syncadapter/FileSyncAdapter.java
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

index 2bb3672..2aab922 100644 (file)
@@ -259,10 +259,10 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
             if (synchFolderOp.getForgottenLocalFiles().size() > 0) {
                 mForgottenLocalFiles.putAll(synchFolderOp.getForgottenLocalFiles());
             }
-            if (result.isSuccess() && synchFolderOp.getRemoteFolderChanged()) {
+            if (result.isSuccess()) {
                 // synchronize children folders 
                 List<OCFile> children = synchFolderOp.getChildren();
-                fetchChildren(folder, children);    // beware of the 'hidden' recursion here!
+                fetchChildren(folder, children, synchFolderOp.getRemoteFolderChanged());    // beware of the 'hidden' recursion here!
             }
             
         } else {
@@ -307,15 +307,22 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
      * 
      * @param files         Files to recursively synchronize.
      */
-    private void fetchChildren(OCFile parent, List<OCFile> files) {
+    private void fetchChildren(OCFile parent, List<OCFile> files, boolean parentEtagChanged) {
         int i;
+        OCFile newFile = null;
+        String etag = null;
+        boolean syncDown = false;
         for (i=0; i < files.size() && !mCancellation; i++) {
-            OCFile newFile = files.get(i);
+            newFile = files.get(i);
             if (newFile.isFolder()) {
-                synchronizeFolder(newFile);
-                // update the size of the parent folder again after recursive synchronization 
-                getStorageManager().updateFolderSize(parent.getFileId());  
-                sendStickyBroadcast(true, parent.getRemotePath(), null);        // notify again to refresh size in UI
+                etag = newFile.getEtag();
+                syncDown = (parentEtagChanged || etag == null || etag.length() == 0);
+                if(syncDown) {
+                    synchronizeFolder(newFile);
+                    // update the size of the parent folder again after recursive synchronization 
+                    getStorageManager().updateFolderSize(parent.getFileId());  
+                    sendStickyBroadcast(true, parent.getRemotePath(), null);        // notify again to refresh size in UI
+                }
             }
         }
        
index 5eaa76c..cb7ff05 100644 (file)
@@ -235,6 +235,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
             if (!stateWasRecovered) {
                 Log_OC.e(TAG, "Initializing Fragments in onAccountChanged..");
                 initFragmentsWithFile();
+                if (file.isFolder()) {
+                    startSyncFolderOperation(file);
+                }
                 
             } else {
                 updateFragmentsVisibility(!file.isFolder());