summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-07-25 23:08:53 +0200
committerBart Visscher <bartv@thisnet.nl>2012-07-25 23:09:03 +0200
commit783d67be6285d730ab7f365e3643bde0c116611a (patch)
tree54b817b28ae18d9c55dabf1390f6ca69a0cc5b03
parent381e493a8c777a4e5e95fd72c6a7ed8114c3c978 (diff)
downloadnextcloud-server-783d67be6285d730ab7f365e3643bde0c116611a.tar.gz
nextcloud-server-783d67be6285d730ab7f365e3643bde0c116611a.zip
Create uniqid ETag for directories
-rw-r--r--lib/connector/sabre/directory.php20
-rw-r--r--lib/connector/sabre/file.php9
-rw-r--r--lib/connector/sabre/node.php11
-rw-r--r--lib/filesystem.php1
4 files changed, 40 insertions, 1 deletions
diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php
index 7003a920277..7f8434c7151 100644
--- a/lib/connector/sabre/directory.php
+++ b/lib/connector/sabre/directory.php
@@ -170,5 +170,25 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
}
+ /**
+ * Returns a list of properties for this nodes.;
+ *
+ * The properties list is a list of propertynames the client requested,
+ * encoded as xmlnamespace#tagName, for example:
+ * http://www.example.org/namespace#author
+ * If the array is empty, all properties should be returned
+ *
+ * @param array $properties
+ * @return void
+ */
+ public function getProperties($properties) {
+ $props = parent::getProperties($properties);
+ if (in_array(self::GETETAG_PROPERTYNAME, $properties)
+ && !isset($props[self::GETETAG_PROPERTYNAME])) {
+ $props[self::GETETAG_PROPERTYNAME] =
+ OC_Connector_Sabre_Node::getETagPropertyForPath($this->path);
+ }
+ return $props;
+ }
}
diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php
index 4fd50591071..9d571fceb0d 100644
--- a/lib/connector/sabre/file.php
+++ b/lib/connector/sabre/file.php
@@ -102,6 +102,15 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
}
/**
+ * Creates a ETag for this path.
+ * @param string $path Path of the file
+ * @return string|null Returns null if the ETag can not effectively be determined
+ */
+ static protected function createETag($path) {
+ return OC_Filesystem::hash('md5', $path);
+ }
+
+ /**
* Returns the mime-type for a file
*
* If null is returned, we'll assume application/octet-stream
diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php
index 77aff92cc39..22506f27cf6 100644
--- a/lib/connector/sabre/node.php
+++ b/lib/connector/sabre/node.php
@@ -204,12 +204,21 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
}
/**
+ * Creates a ETag for this path.
+ * @param string $path Path of the file
+ * @return string|null Returns null if the ETag can not effectively be determined
+ */
+ static protected function createETag($path) {
+ return uniqid('', true);
+ }
+
+ /**
* Returns the ETag surrounded by double-quotes for this path.
* @param string $path Path of the file
* @return string|null Returns null if the ETag can not effectively be determined
*/
static public function getETagPropertyForPath($path) {
- $tag = OC_Filesystem::hash('md5', $path);
+ $tag = self::createETag($path);
if (empty($tag)) {
return null;
}
diff --git a/lib/filesystem.php b/lib/filesystem.php
index c87bc9ed9cb..d88b30c2f68 100644
--- a/lib/filesystem.php
+++ b/lib/filesystem.php
@@ -476,6 +476,7 @@ class OC_Filesystem{
static public function removeETagHook($params) {
$path=$params['path'];
OC_Connector_Sabre_Node::removeETagPropertyForPath($path);
+ OC_Connector_Sabre_Node::removeETagPropertyForPath(dirname($path));
}
}
OC_Hook::connect('OC_Filesystem','post_write', 'OC_Filesystem','removeETagHook');