Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/src/main/java/com/phpbg/easysync/dav/WebDavService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import java.nio.file.Paths
import java.nio.file.StandardCopyOption
import java.nio.file.attribute.FileTime
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter.ISO_DATE_TIME
import java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME
import java.util.concurrent.TimeUnit

Expand Down Expand Up @@ -334,7 +335,7 @@ class WebDavService(
"creationdate" -> resource = resource.copy(
creationdate = ZonedDateTime.parse(
text,
RFC_1123_DATE_TIME
ISO_DATE_TIME // encoded in rfc3339 according to webdav spec
).toInstant()
)

Expand Down
18 changes: 18 additions & 0 deletions app/src/test/java/com/phpbg/easysync/dav/ParseTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ class ParseTest {
assert(expected == res.first())
}

@Test
fun propfind_apache_file_works() {
val stream = this.javaClass.classLoader.getResourceAsStream("file_apache.xml")
val rootPath = RootPath("https://foo")
val res = WebDavService.parsePropfind(stream.reader(), rootPath)
val expected = Resource(
rootPath = rootPath,
href = "/remote.php/dav/files/foouser/DCIM/bar.jpg",
creationdate = ZonedDateTime.parse("2024-01-08T19:14:11Z", DateTimeFormatter.ISO_DATE_TIME).toInstant(),
getlastmodified = ZonedDateTime.parse("Mon, 08 Jan 2024 19:14:11 GMT", DateTimeFormatter.RFC_1123_DATE_TIME).toInstant(),
isCollection = false,
getetag = "\"bacfa6f123dee073dc9e20774470681a\"",
getcontentlength = "425623",
getcontenttype = "image/jpeg"
)
assert(expected == res.first())
}

@Test
fun propfind_uri_decode_works() {
val stream = this.javaClass.classLoader.getResourceAsStream("file_uri_encoded.xml")
Expand Down
16 changes: 16 additions & 0 deletions app/src/test/resources/file_apache.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<d:multistatus xmlns:d="DAV:">
<d:response>
<d:href>/remote.php/dav/files/foouser/DCIM/bar.jpg</d:href>
<d:propstat>
<d:prop>
<d:creationdate>2024-01-08T19:14:11Z</d:creationdate>
<d:getlastmodified>Mon, 08 Jan 2024 19:14:11 GMT</d:getlastmodified>
<d:getcontentlength>425623</d:getcontentlength>
<d:resourcetype/>
<d:getetag>&quot;bacfa6f123dee073dc9e20774470681a&quot;</d:getetag>
<d:getcontenttype>image/jpeg</d:getcontenttype>
</d:prop>
<d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>
</d:response>
</d:multistatus>