]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use the etag to check for updates in webdav storages where available
authorRobin Appelman <icewind@owncloud.com>
Fri, 27 Jun 2014 15:10:46 +0000 (17:10 +0200)
committerRobin Appelman <icewind@owncloud.com>
Fri, 27 Jun 2014 15:10:46 +0000 (17:10 +0200)
lib/private/files/storage/dav.php

index 8536c65ace9fbd38f23a44d9f4dc06de3d4c8931..64c61873d07cb06b8961a68e1f5f3d3653e9d090 100644 (file)
@@ -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;
+               }
+       }
 }