summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authoricewind1991 <robin@icewind.nl>2014-06-27 19:31:18 +0200
committericewind1991 <robin@icewind.nl>2014-06-27 19:31:18 +0200
commit1a3e698294b4a78aa437ad1aaebc7553fca1589d (patch)
tree9345c07cb5ec36152d98746854ceb5bbd51d0c4a /lib
parent7a1b45c43bcca2de24ef1cc55dd1867b63e1462e (diff)
parent1bb1504d2452ccf1fde24700d11dd105805d762d (diff)
downloadnextcloud-server-1a3e698294b4a78aa437ad1aaebc7553fca1589d.tar.gz
nextcloud-server-1a3e698294b4a78aa437ad1aaebc7553fca1589d.zip
Merge pull request #9263 from owncloud/remote-share-update
Better detecting of remote changes for external shares
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/storage/dav.php69
1 files changed, 54 insertions, 15 deletions
diff --git a/lib/private/files/storage/dav.php b/lib/private/files/storage/dav.php
index 8536c65ace9..8b97f750204 100644
--- a/lib/private/files/storage/dav.php
+++ b/lib/private/files/storage/dav.php
@@ -426,21 +426,7 @@ class DAV extends \OC\Files\Storage\Common {
$this->init();
$response = $this->client->propfind($this->encodePath($path), array('{http://owncloud.org/ns}permissions'));
if (isset($response['{http://owncloud.org/ns}permissions'])) {
- $permissions = \OCP\PERMISSION_READ;
- $permissionsString = $response['{http://owncloud.org/ns}permissions'];
- if (strpos($permissionsString, 'R') !== false) {
- $permissions |= \OCP\PERMISSION_SHARE;
- }
- if (strpos($permissionsString, 'D') !== false) {
- $permissions |= \OCP\PERMISSION_DELETE;
- }
- if (strpos($permissionsString, 'W') !== false) {
- $permissions |= \OCP\PERMISSION_UPDATE;
- }
- if (strpos($permissionsString, 'C') !== false) {
- $permissions |= \OCP\PERMISSION_CREATE;
- }
- return $permissions;
+ return $this->parsePermissions($response['{http://owncloud.org/ns}permissions']);
} else if ($this->is_dir($path)) {
return \OCP\PERMISSION_ALL;
} else if ($this->file_exists($path)) {
@@ -449,5 +435,58 @@ class DAV extends \OC\Files\Storage\Common {
return 0;
}
}
+
+ /**
+ * @param string $permissionsString
+ * @return int
+ */
+ protected function parsePermissions($permissionsString) {
+ $permissions = \OCP\PERMISSION_READ;
+ if (strpos($permissionsString, 'R') !== false) {
+ $permissions |= \OCP\PERMISSION_SHARE;
+ }
+ if (strpos($permissionsString, 'D') !== false) {
+ $permissions |= \OCP\PERMISSION_DELETE;
+ }
+ if (strpos($permissionsString, 'W') !== false) {
+ $permissions |= \OCP\PERMISSION_UPDATE;
+ }
+ if (strpos($permissionsString, 'CK') !== false) {
+ $permissions |= \OCP\PERMISSION_CREATE;
+ $permissions |= \OCP\PERMISSION_UPDATE;
+ }
+ return $permissions;
+ }
+
+ /**
+ * 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',
+ '{http://owncloud.org/ns}permissions'
+ ));
+ if (isset($response['{DAV:}getetag'])) {
+ $cachedData = $this->getCache()->get($path);
+ $etag = trim($response['{DAV:}getetag'], '"');
+ if ($cachedData['etag'] !== $etag) {
+ return true;
+ } else if (isset($response['{http://owncloud.org/ns}permissions'])) {
+ $permissions = $this->parsePermissions($response['{http://owncloud.org/ns}permissions']);
+ return $permissions !== $cachedData['permissions'];
+ } else {
+ return false;
+ }
+ } else {
+ $remoteMtime = strtotime($response['{DAV:}getlastmodified']);
+ return $remoteMtime > $time;
+ }
+ }
}