Feat: Update dav4jvm

This commit is contained in:
Hai Zhang 2024-02-27 21:39:59 -08:00
parent feda428f46
commit d74b22721f
5 changed files with 12 additions and 33 deletions

View File

@ -104,9 +104,7 @@ repositories {
}
}
dependencies {
// TODO: Remove DavResource.moveCompat once https://github.com/bitfireAT/dav4jvm/issues/39 is
// fixed.
implementation 'com.github.bitfireAT:dav4jvm:2.2.1'
implementation 'com.github.zhanghai:dav4jvm:59aa867'
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
releaseImplementation 'com.github.mypplication:stetho-noop:1.1'
implementation 'com.github.topjohnwu.libsu:service:5.2.2'

View File

@ -18,10 +18,10 @@ import at.bitfire.dav4jvm.exception.NotFoundException
import at.bitfire.dav4jvm.exception.PreconditionFailedException
import at.bitfire.dav4jvm.exception.ServiceUnavailableException
import at.bitfire.dav4jvm.exception.UnauthorizedException
import at.bitfire.dav4jvm.property.CreationDate
import at.bitfire.dav4jvm.property.GetContentLength
import at.bitfire.dav4jvm.property.GetLastModified
import at.bitfire.dav4jvm.property.ResourceType
import at.bitfire.dav4jvm.property.webdav.CreationDate
import at.bitfire.dav4jvm.property.webdav.GetContentLength
import at.bitfire.dav4jvm.property.webdav.GetLastModified
import at.bitfire.dav4jvm.property.webdav.ResourceType
import java8.nio.channels.SeekableByteChannel
import me.zhanghai.android.files.app.okHttpClient
import me.zhanghai.android.files.compat.toDateCompat
@ -116,7 +116,7 @@ object Client {
throw IOException("Paths aren't on the same authority")
}
try {
DavResource(getClient(source.authority), source.url).moveCompat(target.url, false) {}
DavResource(getClient(source.authority), source.url).move(target.url, false) {}
} catch (e: IOException) {
throw e.toDavException()
}

View File

@ -15,7 +15,6 @@ import me.zhanghai.android.files.provider.common.DelegateOutputStream
import okhttp3.Call
import okhttp3.Callback
import okhttp3.Headers
import okhttp3.HttpUrl
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.Request
@ -32,15 +31,7 @@ import java.util.concurrent.CountDownLatch
@Throws(DavException::class, IOException::class)
fun DavResource.getCompat(accept: String, headers: Headers?): InputStream =
followRedirects {
val request = Request.Builder().get().url(location)
if (headers != null) {
request.headers(headers)
}
// always Accept header
request.header("Accept", accept)
httpClient.newCall(request.build()).execute()
}.also { checkStatus(it) }.body!!.byteStream()
get(accept, headers).also { checkStatus(it) }.body!!.byteStream()
@Throws(DavException::class, IOException::class)
fun DavResource.getRangeCompat(
@ -136,16 +127,6 @@ fun DavResource.getPatchSupport(): PatchSupport {
return patchSupport
}
// https://github.com/bitfireAT/dav4jvm/issues/39
@Throws(DavException::class, IOException::class)
fun DavResource.moveCompat(
destination: HttpUrl,
forceOverride: Boolean,
callback: ResponseCallback
) {
move(destination, !forceOverride, callback)
}
// https://sabre.io/dav/http-patch/
@Throws(DavException::class, IOException::class)
fun DavResource.patchCompat(

View File

@ -6,7 +6,7 @@
package me.zhanghai.android.files.provider.webdav.client
import at.bitfire.dav4jvm.DavResource
import at.bitfire.dav4jvm.property.GetContentLength
import at.bitfire.dav4jvm.property.webdav.GetContentLength
import me.zhanghai.android.files.provider.common.AbstractFileByteChannel
import me.zhanghai.android.files.provider.common.readFully
import okhttp3.RequestBody.Companion.toRequestBody

View File

@ -7,10 +7,10 @@ package me.zhanghai.android.files.provider.webdav.client
import at.bitfire.dav4jvm.HttpUtils
import at.bitfire.dav4jvm.Response
import at.bitfire.dav4jvm.property.CreationDate
import at.bitfire.dav4jvm.property.GetContentLength
import at.bitfire.dav4jvm.property.GetLastModified
import at.bitfire.dav4jvm.property.ResourceType
import at.bitfire.dav4jvm.property.webdav.CreationDate
import at.bitfire.dav4jvm.property.webdav.GetContentLength
import at.bitfire.dav4jvm.property.webdav.GetLastModified
import at.bitfire.dav4jvm.property.webdav.ResourceType
import me.zhanghai.android.files.compat.toInstantCompat
import org.threeten.bp.Instant