diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-11-08 17:47:00 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-11-08 17:48:26 +0100 |
commit | 706bb3ccd654f76c0a6c5b7874fcc1e288b13f54 (patch) | |
tree | 727e84b0c4337abd8855f77f98868bdd9eb4133e | |
parent | 72c38686449a8887d8441377a11f0bfc910bc31f (diff) | |
download | nextcloud-server-706bb3ccd654f76c0a6c5b7874fcc1e288b13f54.tar.gz nextcloud-server-706bb3ccd654f76c0a6c5b7874fcc1e288b13f54.zip |
move ETag generation to storage backends
-rw-r--r-- | lib/connector/sabre/node.php | 16 | ||||
-rw-r--r-- | lib/files/filesystem.php | 10 | ||||
-rw-r--r-- | lib/files/storage/common.php | 16 | ||||
-rw-r--r-- | lib/files/storage/storage.php | 8 | ||||
-rw-r--r-- | lib/files/view.php | 15 |
5 files changed, 50 insertions, 15 deletions
diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php index ebc9e539625..d0ab0c24988 100644 --- a/lib/connector/sabre/node.php +++ b/lib/connector/sabre/node.php @@ -211,26 +211,12 @@ 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) { - 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; } diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php index 76a188e4120..ed2814211f4 100644 --- a/lib/files/filesystem.php +++ b/lib/files/filesystem.php @@ -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'); diff --git a/lib/files/storage/common.php b/lib/files/storage/common.php index e22264d0da9..f471752d1ff 100644 --- a/lib/files/storage/common.php +++ b/lib/files/storage/common.php @@ -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); + } + } } diff --git a/lib/files/storage/storage.php b/lib/files/storage/storage.php index 1f5c9356294..bb1ba16984d 100644 --- a/lib/files/storage/storage.php +++ b/lib/files/storage/storage.php @@ -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); } diff --git a/lib/files/view.php b/lib/files/view.php index e3f9b762f7a..a54c3ee3564 100644 --- a/lib/files/view.php +++ b/lib/files/view.php @@ -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); + } } |