Skip to content

Commit

Permalink
Fix: Update dav4jvm and fix parsing WebDAV modified time
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghai committed Mar 3, 2024
1 parent a9bcff4 commit 0854aac
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ repositories {
}
}
dependencies {
implementation 'com.github.zhanghai:dav4jvm:59aa867'
implementation 'com.github.zhanghai:dav4jvm:3f4822d'
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
implementation 'com.github.topjohnwu.libsu:service:5.2.2'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ 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
import me.zhanghai.android.files.provider.common.LocalWatchService
import me.zhanghai.android.files.provider.common.NotifyEntryModifiedOutputStream
import me.zhanghai.android.files.provider.common.NotifyEntryModifiedSeekableByteChannel
Expand Down Expand Up @@ -220,9 +219,7 @@ object Client {
// https://github.com/sabre-io/dav/issues/1277
try {
DavResource(getClient(path.authority), path.url).proppatch(
mapOf(
GetLastModified.NAME to HttpUtils.formatDate(lastModifiedTime.toDateCompat())
), emptyList()
mapOf(GetLastModified.NAME to HttpUtils.formatDate(lastModifiedTime)), emptyList()
) { response, _ -> response.checkSuccess() }
} catch (e: IOException) {
throw e.toDavException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ 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

val Response.creationTime: Instant?
get() =
this[CreationDate::class.java]?.creationDate?.let { HttpUtils.parseDate(it) }
?.toInstantCompat()
this[CreationDate::class.java]?.creationDate?.let { HttpUtils.parseDate(it) }?.toInstant()

val Response.isDirectory: Boolean
get() = this[ResourceType::class.java]?.types?.contains(ResourceType.COLLECTION) == true
Expand All @@ -27,7 +25,7 @@ val Response.isSymbolicLink: Boolean

val Response.lastModifiedTime: Instant?
get() =
this[GetLastModified::class.java]?.lastModified?.let { Instant.ofEpochMilli(it) }
this[GetLastModified::class.java]?.lastModified?.toInstant()

val Response.size: Long
get() = this[GetContentLength::class.java]?.contentLength ?: 0

0 comments on commit 0854aac

Please sign in to comment.