diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-04-01 21:16:29 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-05-30 16:10:30 +0200 |
commit | 5d7f37d57065715f09db2b61654044a027df4e91 (patch) | |
tree | 52694daaaf0b06138f0ba95e1059f46c8d80630a | |
parent | 6f346b4b1f4512668e631ac57e71fac9061bc5fe (diff) | |
download | nextcloud-server-5d7f37d57065715f09db2b61654044a027df4e91.tar.gz nextcloud-server-5d7f37d57065715f09db2b61654044a027df4e91.zip |
Check whether remote DAV server accepted the mtime on touch
ownCloud as remote DAV always accepts the mtime on touch, but other
servers like Apache's DAV server doesn't. The latter doesn't give any
visible hint in its response to detect this case, so this fix does a
subsequent PROPFIND to check whether the mtime was actually set.
Since a touch() operation seldom happens (only on uploads), the minor
performance loss should hopefully be acceptable.
-rw-r--r-- | lib/private/Files/Storage/DAV.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index 4713eb86fc0..0d41b3bab02 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -449,7 +449,16 @@ class DAV extends Common { if ($this->file_exists($path)) { try { $this->statCache->remove($path); - $this->client->proppatch($this->encodePath($path), array('{DAV:}lastmodified' => $mtime)); + $this->client->proppatch($this->encodePath($path), ['{DAV:}lastmodified' => $mtime]); + // non-owncloud clients might not have accepted the property, need to recheck it + $response = $this->client->propfind($this->encodePath($path), ['{DAV:}getlastmodified'], 0); + if (isset($response['{DAV:}getlastmodified'])) { + $remoteMtime = strtotime($response['{DAV:}getlastmodified']); + if ($remoteMtime !== $mtime) { + // server has not accepted the mtime + return false; + } + } } catch (ClientHttpException $e) { if ($e->getHttpStatus() === 501) { return false; |