]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow changing the way etags are generated
authorRobin Appelman <icewind@owncloud.com>
Wed, 7 Nov 2012 13:21:34 +0000 (14:21 +0100)
committerRobin Appelman <icewind@owncloud.com>
Wed, 7 Nov 2012 16:03:59 +0000 (17:03 +0100)
lib/connector/sabre/node.php

index 72de972377499da25b1c51aef7bd3c2537aad31b..f87e9f9a0b1122db3c8f93edd368ede2e937d3e2 100644 (file)
@@ -25,6 +25,13 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
        const GETETAG_PROPERTYNAME = '{DAV:}getetag';
        const LASTMODIFIED_PROPERTYNAME = '{DAV:}lastmodified';
 
+       /**
+        * Allow configuring the method used to generate Etags
+        *
+        * @var array(class_name, function_name)
+       */
+       public static $ETagFunction = null;
+
        /**
         * The path to the current node
         *
@@ -178,7 +185,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
         * If the array is empty, all properties should be returned
         *
         * @param array $properties
-        * @return void
+        * @return array
         */
        public function getProperties($properties) {
                if (is_null($this->property_cache)) {
@@ -209,7 +216,12 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
         * @return string|null Returns null if the ETag can not effectively be determined
         */
        static protected function createETag($path) {
-               return uniqid('', true);
+               if(self::$ETagFunction) {
+                       $hash = call_user_func(self::$ETagFunction, $path);
+                       return $hash;
+               }else{
+                       return uniqid('', true);
+               }
        }
 
        /**