Fix PROPFIND fallback for lighttpd as well
This commit is contained in:
parent
1dd898b068
commit
56e26083fc
2 changed files with 14 additions and 2 deletions
|
@ -142,7 +142,7 @@ internal abstract class WebDavStorage(
|
||||||
callback = callback,
|
callback = callback,
|
||||||
)
|
)
|
||||||
} catch (e: HttpException) {
|
} catch (e: HttpException) {
|
||||||
if (e.code == 400) {
|
if (e.isUnsupportedPropfind()) {
|
||||||
Log.i(TAG, "Got ${e.response}, trying two depth=1 PROPFINDs...")
|
Log.i(TAG, "Got ${e.response}, trying two depth=1 PROPFINDs...")
|
||||||
propfindFakeTwo(callback)
|
propfindFakeTwo(callback)
|
||||||
} else {
|
} else {
|
||||||
|
@ -169,6 +169,18 @@ internal abstract class WebDavStorage(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected fun HttpException.isUnsupportedPropfind(): Boolean {
|
||||||
|
// nginx returns 400 for depth=2
|
||||||
|
if (code == 400) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
// lighttpd returns 403 with <DAV:propfind-finite-depth/> error as if we used infinity
|
||||||
|
if (code == 403 && responseBody?.contains("propfind-finite-depth") == true) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
protected suspend fun DavCollection.createFolder(xmlBody: String? = null): okhttp3.Response {
|
protected suspend fun DavCollection.createFolder(xmlBody: String? = null): okhttp3.Response {
|
||||||
return try {
|
return try {
|
||||||
suspendCoroutine { cont ->
|
suspendCoroutine { cont ->
|
||||||
|
|
|
@ -192,7 +192,7 @@ internal class WebDavStoragePlugin(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: HttpException) {
|
} catch (e: HttpException) {
|
||||||
if (e.code == 400) getBackupTokenWithDepthOne(davCollection, tokens)
|
if (e.isUnsupportedPropfind()) getBackupTokenWithDepthOne(davCollection, tokens)
|
||||||
else throw e
|
else throw e
|
||||||
}
|
}
|
||||||
val tokenIterator = tokens.iterator()
|
val tokenIterator = tokens.iterator()
|
||||||
|
|
Loading…
Reference in a new issue