diff --git a/README.md b/README.md index 7ebfe9d..ec3e096 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ Its original purpose was to serve as a demo and test for the KD2 WebDAV library, ### NextCloud/ownCloud features +KaraDAV is compatible with ownCloud and NextCloud clients, because on Android there is not much nice WebDAV clients, and on desktop their clients allow for two-way sync, which no other WebDAV client provides. + The following ownCloud/NextCloud specific features are supported: * [Direct download](https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-api-overview.html#direct-download) diff --git a/lib/KD2/WebDAV/AbstractStorage.php b/lib/KD2/WebDAV/AbstractStorage.php index a5c1df9..088b7a4 100644 --- a/lib/KD2/WebDAV/AbstractStorage.php +++ b/lib/KD2/WebDAV/AbstractStorage.php @@ -105,7 +105,9 @@ abstract class AbstractStorage * @param array $properties List of properties requested by client (see ::properties) * @return iterable An array or other iterable (eg. a generator) * where each item has a key string containing the name of the resource (eg. file name), - * and the value being an array of properties, or NULL + * and the value being an array of properties, or NULL. + * + * If the array value IS NULL, then a subsequent call to properties() will be issued for each element. */ abstract public function list(string $uri, array $properties): iterable; diff --git a/lib/KD2/WebDAV/Server.php b/lib/KD2/WebDAV/Server.php index e462143..f519cce 100644 --- a/lib/KD2/WebDAV/Server.php +++ b/lib/KD2/WebDAV/Server.php @@ -742,6 +742,14 @@ class Server $alias = $root_namespaces[$ns] ?? null; $attributes = ''; + // The ownCloud Android app doesn't like formatted dates, it makes it crash. + // so force it to have a timestamp + if ($name == 'DAV::creationdate' + && ($value instanceof \DateTimeInterface) + && false !== stripos($_SERVER['HTTP_USER_AGENT'] ?? '', 'owncloud')) { + $value = $value->getTimestamp(); + } + if ($name == 'DAV::resourcetype' && $value == 'collection') { $value = ''; } diff --git a/lib/KaraDAV/Storage.php b/lib/KaraDAV/Storage.php index 2b59533..dab785a 100644 --- a/lib/KaraDAV/Storage.php +++ b/lib/KaraDAV/Storage.php @@ -3,7 +3,6 @@ namespace KaraDAV; use KD2\WebDAV\AbstractStorage; -use KD2\WebDAV\Server as WebDAV_Server; use KD2\WebDAV\WOPI; use KD2\WebDAV\Exception as WebDAV_Exception; @@ -130,11 +129,6 @@ class Storage extends AbstractStorage case 'DAV::lastaccessed': return new \DateTime('@' . fileatime($target)); case 'DAV::creationdate': - // The ownCloud Android app doesn't like formatted dates, it makes it crash. - if (false !== stripos($_SERVER['HTTP_USER_AGENT'] ?? '', 'owncloud')) { - return filectime($target); - } - return new \DateTime('@' . filectime($target)); case WebDAV::PROP_DIGEST_MD5: if (!is_file($target)) {