From: David A. Velasco Date: Mon, 21 Oct 2013 11:27:33 +0000 (+0200) Subject: Trigger synchronization of current folder when the app is started or the current... X-Git-Tag: oc-android-1.5.5~155^2~7 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/bb455033763c2fb6bdbda5e1220fb1c820f176da?ds=inline;hp=-c Trigger synchronization of current folder when the app is started or the current account changed --- bb455033763c2fb6bdbda5e1220fb1c820f176da diff --git a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java index 2bb36729..2aab9222 100644 --- a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java +++ b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java @@ -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 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 files) { + private void fetchChildren(OCFile parent, List 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 + } } } diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 5eaa76c7..cb7ff054 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -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());