diff --git a/app/src/main/java/com/phpbg/easysync/dav/WebDavService.kt b/app/src/main/java/com/phpbg/easysync/dav/WebDavService.kt index f7d97b9..7fa6676 100644 --- a/app/src/main/java/com/phpbg/easysync/dav/WebDavService.kt +++ b/app/src/main/java/com/phpbg/easysync/dav/WebDavService.kt @@ -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 @@ -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() ) diff --git a/app/src/test/java/com/phpbg/easysync/dav/ParseTest.kt b/app/src/test/java/com/phpbg/easysync/dav/ParseTest.kt index 0106e64..7e96b6f 100644 --- a/app/src/test/java/com/phpbg/easysync/dav/ParseTest.kt +++ b/app/src/test/java/com/phpbg/easysync/dav/ParseTest.kt @@ -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") diff --git a/app/src/test/resources/file_apache.xml b/app/src/test/resources/file_apache.xml new file mode 100644 index 0000000..f56b624 --- /dev/null +++ b/app/src/test/resources/file_apache.xml @@ -0,0 +1,16 @@ + + + /remote.php/dav/files/foouser/DCIM/bar.jpg + + + 2024-01-08T19:14:11Z + Mon, 08 Jan 2024 19:14:11 GMT + 425623 + + "bacfa6f123dee073dc9e20774470681a" + image/jpeg + + HTTP/1.1 200 OK + + +