Bugfix for issue #220: exception on Android 4.3
[pub/Android/ownCloud.git] / src / com / owncloud / android / syncadapter / FileSyncAdapter.java
index ec8750c..8653fe7 100644 (file)
@@ -37,6 +37,8 @@ import com.owncloud.android.operations.SynchronizeFolderOperation;
 import com.owncloud.android.operations.UpdateOCVersionOperation;
 import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
 import com.owncloud.android.ui.activity.ErrorsWhileCopyingHandlerActivity;
+import com.owncloud.android.utils.FileStorageUtils;
+
 import android.accounts.Account;
 import android.accounts.AccountsException;
 import android.app.Notification;
@@ -218,6 +220,8 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
             List<OCFile> children = synchFolderOp.getChildren();
             fetchChildren(children);    // beware of the 'hidden' recursion here!
             
+            sendStickyBroadcast(true, remotePath, null);
+            
         } else {
             if (result.getCode() == RemoteOperationResult.ResultCode.UNAUTHORIZED) {
                 mSyncResult.stats.numAuthExceptions++;
@@ -263,8 +267,12 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
             OCFile newFile = files.get(i);
             if (newFile.isDirectory()) {
                 fetchData(newFile.getRemotePath(), newFile.getFileId());
+                
+                // Update folder size on DB
+                getStorageManager().calculateFolderSize(newFile.getFileId());                   
             }
         }
+       
         if (mCancellation && i <files.size()) Log_OC.d(TAG, "Leaving synchronization before synchronizing " + files.get(i).getRemotePath() + " because cancelation request");
     }
 
@@ -303,6 +311,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
             // let the user update credentials with one click
             Intent updateAccountCredentials = new Intent(getContext(), AuthenticatorActivity.class);
             updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, getAccount());
+            updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ENFORCED_UPDATE, true);
             updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_TOKEN);
             updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
             updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);