From a9f111f324824dcc771cc83631a09e8b1820603b Mon Sep 17 00:00:00 2001 From: Steffen Ritter Date: Wed, 8 Jan 2014 09:51:28 +0100 Subject: [PATCH 1/1] [TASK] Calculated hash of File object is never used The indexing pre-calculates the file hash and stores it in the sys_file table. Sadly the getter of file objects never looks at this again and always recalculates the hash via the driver, which is very slow. Resolves: #54235 Releases: 6.2, 6.1, 6.0 Change-Id: I16bfa2126031f26b8e31da8d8c0b3fc07d0217dc Reviewed-on: https://review.typo3.org/26689 Reviewed-by: Oliver Hader Tested-by: Oliver Hader Reviewed-by: Oliver Klee Reviewed-by: Benjamin Mack Tested-by: Benjamin Mack --- typo3/sysext/core/Classes/Resource/File.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/typo3/sysext/core/Classes/Resource/File.php b/typo3/sysext/core/Classes/Resource/File.php index d3832aca71fe..9d9967565111 100644 --- a/typo3/sysext/core/Classes/Resource/File.php +++ b/typo3/sysext/core/Classes/Resource/File.php @@ -150,6 +150,18 @@ class File extends AbstractFile { return $this->getStorage()->getFileContents($this); } + /** + * Gets SHA1 hash. + * + * @return string + */ + public function getSha1() { + if (empty($this->properties['sha1'])) { + $this->properties['sha1'] = parent::getSha1(); + } + return $this->properties['sha1']; + } + /** * Replace the current file contents with the given string * -- 2.20.1