move ETag generation to storage backends
This commit is contained in:
parent
72c3868644
commit
706bb3ccd6
|
@ -210,27 +210,13 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
|
|||
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) {
|
||||
if(self::$ETagFunction) {
|
||||
$hash = call_user_func(self::$ETagFunction, $path);
|
||||
return $hash;
|
||||
}else{
|
||||
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 = self::createETag($path);
|
||||
$tag = \OC\Files\Filesystem::getETag($path);
|
||||
if (empty($tag)) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -654,6 +654,16 @@ class Filesystem {
|
|||
public static function getDirectoryContent($directory, $mimetype_filter = '') {
|
||||
return self::$defaultInstance->getDirectoryContent($directory, $mimetype_filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* get the ETag for a file or folder
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
static public function getETag($path){
|
||||
return self::$defaultInstance->getETag($path);
|
||||
}
|
||||
}
|
||||
|
||||
\OC_Hook::connect('OC_Filesystem', 'post_write', 'OC_Filesystem', 'removeETagHook');
|
||||
|
|
|
@ -267,4 +267,20 @@ abstract class Common implements \OC\Files\Storage\Storage {
|
|||
public function getOwner($path) {
|
||||
return \OC_User::getUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* get the ETag for a file or folder
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function getETag($path){
|
||||
$ETagFunction = \OC_Connector_Sabre_Node::$ETagFunction;
|
||||
if($ETagFunction) {
|
||||
$hash = call_user_func($ETagFunction, $path);
|
||||
return $hash;
|
||||
}else{
|
||||
return uniqid('', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,4 +63,12 @@ interface Storage{
|
|||
public function getScanner();
|
||||
|
||||
public function getOwner($path);
|
||||
|
||||
/**
|
||||
* get the ETag for a file or folder
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function getETag($path);
|
||||
}
|
||||
|
|
|
@ -866,4 +866,19 @@ class View {
|
|||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the ETag for a file or folder
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function getETag($path){
|
||||
/**
|
||||
* @var Storage\Storage $storage
|
||||
* @var string $internalPath
|
||||
*/
|
||||
list($storage, $internalPath) = $this->resolvePath($path);
|
||||
return $storage->getETag($internalPath);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue