Create uniqid ETag for directories
This commit is contained in:
parent
381e493a8c
commit
783d67be62
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,15 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
|
||||||
return $this->getETagPropertyForPath($this->path);
|
return $this->getETagPropertyForPath($this->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* Returns the mime-type for a file
|
||||||
*
|
*
|
||||||
|
|
|
@ -203,13 +203,22 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
|
||||||
return $props;
|
return $props;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Returns the ETag surrounded by double-quotes for this path.
|
||||||
* @param string $path Path of the file
|
* @param string $path Path of the file
|
||||||
* @return string|null Returns null if the ETag can not effectively be determined
|
* @return string|null Returns null if the ETag can not effectively be determined
|
||||||
*/
|
*/
|
||||||
static public function getETagPropertyForPath($path) {
|
static public function getETagPropertyForPath($path) {
|
||||||
$tag = OC_Filesystem::hash('md5', $path);
|
$tag = self::createETag($path);
|
||||||
if (empty($tag)) {
|
if (empty($tag)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -476,6 +476,7 @@ class OC_Filesystem{
|
||||||
static public function removeETagHook($params) {
|
static public function removeETagHook($params) {
|
||||||
$path=$params['path'];
|
$path=$params['path'];
|
||||||
OC_Connector_Sabre_Node::removeETagPropertyForPath($path);
|
OC_Connector_Sabre_Node::removeETagPropertyForPath($path);
|
||||||
|
OC_Connector_Sabre_Node::removeETagPropertyForPath(dirname($path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OC_Hook::connect('OC_Filesystem','post_write', 'OC_Filesystem','removeETagHook');
|
OC_Hook::connect('OC_Filesystem','post_write', 'OC_Filesystem','removeETagHook');
|
||||||
|
|
Loading…
Reference in New Issue