Skip to content

Commit

Permalink
Feat: Update dav4jvm
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghai committed Feb 28, 2024
1 parent feda428 commit d74b227
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 33 deletions.
4 changes: 1 addition & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d74b227

Please sign in to comment.