diff options
author | Robin Appelman <robin@icewind.nl> | 2022-03-17 16:05:52 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2022-03-17 22:21:16 +0100 |
commit | 84f464550ad632ecbcd1dbe4b9796053047622a7 (patch) | |
tree | ac9435f94175ea927305cee49407d3527c6a6d97 /lib/private/Files/Storage/Local.php | |
parent | bf48c0b1b4bd3677a70aa0d7c8a50a5253c4cb5b (diff) | |
download | nextcloud-server-84f464550ad632ecbcd1dbe4b9796053047622a7.tar.gz nextcloud-server-84f464550ad632ecbcd1dbe4b9796053047622a7.zip |
some file scanner performance improvements
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Files/Storage/Local.php')
-rw-r--r-- | lib/private/Files/Storage/Local.php | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index 6406beaeebc..34ab9a5fc97 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -47,7 +47,9 @@ use OC\Files\Storage\Wrapper\Jail; use OCP\Constants; use OCP\Files\ForbiddenException; use OCP\Files\GenericFileException; +use OCP\Files\IMimeTypeDetector; use OCP\Files\Storage\IStorage; +use OCP\IConfig; use OCP\ILogger; /** @@ -60,6 +62,10 @@ class Local extends \OC\Files\Storage\Common { protected $realDataDir; + private IConfig $config; + + private IMimeTypeDetector $mimeTypeDetector; + public function __construct($arguments) { if (!isset($arguments['datadir']) || !is_string($arguments['datadir'])) { throw new \InvalidArgumentException('No data directory set for local storage'); @@ -76,6 +82,8 @@ class Local extends \OC\Files\Storage\Common { $this->datadir .= '/'; } $this->dataDirLength = strlen($this->realDataDir); + $this->config = \OC::$server->get(IConfig::class); + $this->mimeTypeDetector = \OC::$server->get(IMimeTypeDetector::class); } public function __destruct() { @@ -155,6 +163,9 @@ class Local extends \OC\Files\Storage\Common { $statResult['size'] = $filesize; $statResult[7] = $filesize; } + if (is_array($statResult)) { + $statResult['full_path'] = $fullPath; + } return $statResult; } @@ -181,15 +192,14 @@ class Local extends \OC\Files\Storage\Common { } if (!($path === '' || $path === '/')) { // deletable depends on the parents unix permissions - $fullPath = $this->getSourcePath($path); - $parent = dirname($fullPath); + $parent = dirname($stat['full_path']); if (is_writable($parent)) { $permissions += Constants::PERMISSION_DELETE; } } $data = []; - $data['mimetype'] = $isDir ? 'httpd/unix-directory' : \OC::$server->getMimeTypeDetector()->detectPath($path); + $data['mimetype'] = $isDir ? 'httpd/unix-directory' : $this->mimeTypeDetector->detectPath($path); $data['mtime'] = $stat['mtime']; if ($data['mtime'] === false) { $data['mtime'] = time(); @@ -450,7 +460,7 @@ class Local extends \OC\Files\Storage\Common { $fullPath = $this->datadir . $path; $currentPath = $path; - $allowSymlinks = \OC::$server->getConfig()->getSystemValue('localstorage.allowsymlinks', false); + $allowSymlinks = $this->config->getSystemValue('localstorage.allowsymlinks', false); if ($allowSymlinks || $currentPath === '') { return $fullPath; } |