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,
|
||||
)
|
||||
} catch (e: HttpException) {
|
||||
if (e.code == 400) {
|
||||
if (e.isUnsupportedPropfind()) {
|
||||
Log.i(TAG, "Got ${e.response}, trying two depth=1 PROPFINDs...")
|
||||
propfindFakeTwo(callback)
|
||||
} 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 {
|
||||
return try {
|
||||
suspendCoroutine { cont ->
|
||||
|
|
|
@ -192,7 +192,7 @@ internal class WebDavStoragePlugin(
|
|||
}
|
||||
}
|
||||
} catch (e: HttpException) {
|
||||
if (e.code == 400) getBackupTokenWithDepthOne(davCollection, tokens)
|
||||
if (e.isUnsupportedPropfind()) getBackupTokenWithDepthOne(davCollection, tokens)
|
||||
else throw e
|
||||
}
|
||||
val tokenIterator = tokens.iterator()
|
||||
|
|
Loading…
Reference in a new issue