Commit bc5f1e93 authored by Ricki Hirner's avatar Ricki Hirner

Ignore HTTP 403 when the resource upload fails because of missing permissions (server will win)

parent 72749add
Pipeline #41021764 passed with stages
in 12 minutes and 47 seconds
......@@ -18,7 +18,7 @@ android {
defaultConfig {
applicationId "at.bitfire.davdroid"
versionCode 251
versionCode 252
buildConfigField "long", "buildTime", System.currentTimeMillis() + "L"
buildConfigField "boolean", "customCerts", "true"
......@@ -90,8 +90,8 @@ dependencies {
implementation 'org.apache.commons:commons-collections4:4.2'
// for tests
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test:rules:1.1.0'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test:rules:1.1.1'
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.12.0'
......
......@@ -170,7 +170,7 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L
syncState = SyncState.fromSyncToken(result.first, initialSync)
furtherChanges = result.second
} catch(e: HttpException) {
if (e.errors.any { it.name == Property.Name(XmlUtils.NS_WEBDAV, "valid-sync-token") }) {
if (e.errors.contains(Error.VALID_SYNC_TOKEN)) {
Logger.log.info("Sync token invalid, performing initial sync")
initialSync = true
resetPresentRemotely()
......@@ -326,10 +326,20 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L
remote.put(body, local.eTag, false, processETag)
}
numUploaded++
} catch(e: ForbiddenException) {
// HTTP 403 Forbidden
// If and only if the upload failed because of missing permissions, treat it like 412.
if (e.errors.contains(Error.NEED_PRIVILEGES))
Logger.log.log(Level.INFO, "Couldn't upload because of missing permissions, ignoring", e)
else
throw e
} catch(e: ConflictException) {
// we can't interact with the user to resolve the conflict, so we treat 409 like 412
// HTTP 409 Conflict
// We can't interact with the user to resolve the conflict, so we treat 409 like 412.
Logger.log.log(Level.INFO, "Edit conflict, ignoring", e)
} catch(e: PreconditionFailedException) {
// HTTP 412 Precondition failed: Resource has been modified on the server in the meanwhile.
// Ignore this condition so that the resource can be downloaded and reset again.
Logger.log.log(Level.INFO, "Resource has been modified on the server before upload, ignoring", e)
}
......
......@@ -8,7 +8,7 @@
buildscript {
ext.dokka_version = '0.9.17'
ext.kotlin_version = '1.3.10'
ext.kotlin_version = '1.3.11'
repositories {
jcenter()
......
Subproject commit cad85fee5d0d3649df3e1cbc6a03c4a1645560d8
Subproject commit 2c7523be31985e683cedd342c48829dbee096c67
Subproject commit 5b0cad59f2231b98185643e90edfa9af7ade53b4
Subproject commit e04df070148adaf4ddc454a97350ffe46280ee2b
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment