X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/bdc0332c23b326d21193f71ff7db2cf587de0c43..c2abbaaedb69dba35866a48b745b68f3519cbca1:/src/com/owncloud/android/syncadapter/FileSyncAdapter.java diff --git a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java index b3a42ea3..a0ca9881 100644 --- a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java +++ b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java @@ -19,7 +19,6 @@ package com.owncloud.android.syncadapter; import java.io.IOException; -import java.net.UnknownHostException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -28,7 +27,9 @@ import java.util.Map; import org.apache.jackrabbit.webdav.DavException; import com.owncloud.android.Log_OC; +import com.owncloud.android.MainApp; import com.owncloud.android.R; +import com.owncloud.android.authentication.AuthenticatorActivity; import com.owncloud.android.datamodel.DataStorageManager; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; @@ -37,7 +38,10 @@ 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 android.accounts.Account; +import android.accounts.AccountsException; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; @@ -47,13 +51,13 @@ import android.content.Context; import android.content.Intent; import android.content.SyncResult; import android.os.Bundle; -import android.util.Log; /** * SyncAdapter implementation for syncing sample SyncAdapter contacts to the * platform ContactOperations provider. * * @author Bartek Przybylski + * @author David A. Velasco */ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { @@ -103,8 +107,13 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { this.setStorageManager(new FileDataStorageManager(account, getContentProvider())); try { this.initClientForCurrentAccount(); - } catch (UnknownHostException e) { - /// the account is unknown for the Synchronization Manager. unreachable for this context; don't try this again + } catch (IOException e) { + /// the account is unknown for the Synchronization Manager, or unreachable for this context; don't try this again + mSyncResult.tooManyRetries = true; + notifyFailedSynchronization(); + return; + } catch (AccountsException e) { + /// the account is unknown for the Synchronization Manager, or unreachable for this context; don't try this again mSyncResult.tooManyRetries = true; notifyFailedSynchronization(); return; @@ -147,7 +156,6 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { } } - /** * Called by system SyncManager when a synchronization is required to be cancelled. @@ -173,7 +181,6 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { mLastFailedResult = result; } } - /** @@ -214,8 +221,13 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { List children = synchFolderOp.getChildren(); fetchChildren(children); // beware of the 'hidden' recursion here! + sendStickyBroadcast(true, remotePath, null); + } else { - if (result.getCode() == RemoteOperationResult.ResultCode.UNAUTHORIZED) { + if (result.getCode() == RemoteOperationResult.ResultCode.UNAUTHORIZED || + // (result.isTemporalRedirection() && result.isIdPRedirection() && + ( result.isIdPRedirection() && + MainApp.getAuthTokenTypeSamlSessionCookie().equals(getClient().getAuthTokenType()))) { mSyncResult.stats.numAuthExceptions++; } else if (result.getException() instanceof DavException) { @@ -259,8 +271,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