Sync adapter: handle some etebase exceptions.

pull/131/head
Tom Hacohen 4 years ago
parent f8c0eaca35
commit 52b7a84a1a

@ -23,6 +23,9 @@ import androidx.core.util.Pair
import at.bitfire.ical4android.CalendarStorageException
import at.bitfire.vcard4android.ContactsStorageException
import com.etebase.client.FetchOptions
import com.etebase.client.exceptions.ConnectionException
import com.etebase.client.exceptions.TemporaryServerErrorException
import com.etebase.client.exceptions.UnauthorizedException
import com.etesync.syncadapter.*
import com.etesync.journalmanager.Crypto
import com.etesync.journalmanager.Exceptions
@ -118,6 +121,12 @@ abstract class SyncAdapterService : Service() {
} catch (e: Exceptions.ServiceUnavailableException) {
syncResult.stats.numIoExceptions++
syncResult.delayUntil = if (e.retryAfter > 0) e.retryAfter else Constants.DEFAULT_RETRY_DELAY
} catch (e: TemporaryServerErrorException) {
syncResult.stats.numIoExceptions++
syncResult.delayUntil = Constants.DEFAULT_RETRY_DELAY
} catch (e: ConnectionException) {
syncResult.stats.numIoExceptions++
syncResult.delayUntil = Constants.DEFAULT_RETRY_DELAY
} catch (e: Exceptions.IgnorableHttpException) {
// Ignore
} catch (e: Exception) {
@ -133,7 +142,7 @@ abstract class SyncAdapterService : Service() {
val detailsIntent = notificationManager.detailsIntent
detailsIntent.putExtra(Constants.KEY_ACCOUNT, account)
if (e !is Exceptions.UnauthorizedException) {
if (e !is Exceptions.UnauthorizedException && e !is UnauthorizedException) {
detailsIntent.putExtra(DebugInfoActivity.KEY_AUTHORITY, authority)
detailsIntent.putExtra(DebugInfoActivity.KEY_PHASE, syncPhase)
}

@ -17,6 +17,10 @@ import at.bitfire.ical4android.CalendarStorageException
import at.bitfire.ical4android.InvalidCalendarException
import at.bitfire.vcard4android.ContactsStorageException
import com.etebase.client.*
import com.etebase.client.exceptions.ConnectionException
import com.etebase.client.exceptions.HttpException
import com.etebase.client.exceptions.TemporaryServerErrorException
import com.etebase.client.exceptions.UnauthorizedException
import com.etesync.syncadapter.*
import com.etesync.syncadapter.Constants.KEY_ACCOUNT
import com.etesync.journalmanager.Crypto
@ -275,15 +279,21 @@ constructor(protected val context: Context, protected val account: Account, prot
} catch (e: Exceptions.ServiceUnavailableException) {
syncResult.stats.numIoExceptions++
syncResult.delayUntil = if (e.retryAfter > 0) e.retryAfter else Constants.DEFAULT_RETRY_DELAY
} catch (e: TemporaryServerErrorException) {
syncResult.stats.numIoExceptions++
syncResult.delayUntil = Constants.DEFAULT_RETRY_DELAY
} catch (e: ConnectionException) {
syncResult.stats.numIoExceptions++
syncResult.delayUntil = Constants.DEFAULT_RETRY_DELAY
} catch (e: InterruptedException) {
// Restart sync if interrupted
syncResult.fullSyncRequested = true
} catch (e: Exceptions.IgnorableHttpException) {
// Ignore
} catch (e: Exception) {
if (e is Exceptions.UnauthorizedException) {
if (e is Exceptions.UnauthorizedException || e is UnauthorizedException) {
syncResult.stats.numAuthExceptions++
} else if (e is Exceptions.HttpException) {
} else if (e is Exceptions.HttpException || e is HttpException) {
syncResult.stats.numParseExceptions++
} else if (e is CalendarStorageException || e is ContactsStorageException) {
syncResult.databaseError = true

Loading…
Cancel
Save