summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-06-27 17:10:46 +0200
committerRobin Appelman <icewind@owncloud.com>2014-06-27 17:10:46 +0200
commit5b8c2ac750e79e574b49e0ba7ac866f0d5002003 (patch)
tree1d2825134ef23cebd9e6540eaf0553599cbb8735
parent3b2fd5e4e6aad769f656c473f1a1fe53f5936c47 (diff)
downloadnextcloud-server-5b8c2ac750e79e574b49e0ba7ac866f0d5002003.tar.gz
nextcloud-server-5b8c2ac750e79e574b49e0ba7ac866f0d5002003.zip
Use the etag to check for updates in webdav storages where available
-rw-r--r--lib/private/files/storage/dav.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/private/files/storage/dav.php b/lib/private/files/storage/dav.php
index 8536c65ace9..64c61873d07 100644
--- a/lib/private/files/storage/dav.php
+++ b/lib/private/files/storage/dav.php
@@ -449,5 +449,24 @@ class DAV extends \OC\Files\Storage\Common {
return 0;
}
}
+
+ /**
+ * check if a file or folder has been updated since $time
+ *
+ * @param string $path
+ * @param int $time
+ * @return bool
+ */
+ public function hasUpdated($path, $time) {
+ $this->init();
+ $response = $this->client->propfind($this->encodePath($path), array('{DAV:}getlastmodified', '{DAV:}getetag'));
+ if (isset($response['{DAV:}getetag'])) {
+ $cachedData = $this->getCache()->get($path);
+ return $cachedData['etag'] !== $response['{DAV:}getetag'];
+ } else {
+ $remoteMtime = strtotime($response['{DAV:}getlastmodified']);
+ return $remoteMtime > $time;
+ }
+ }
}