From 4fd805abd1d736ed0201fe4284df3b42b635ddea Mon Sep 17 00:00:00 2001 From: Olivier Paroz Date: Tue, 21 Apr 2015 19:21:23 +0200 Subject: [PATCH] Only allow locally mounted storage on which the preview system has been enabled Fixes #13 --- service/filesservice.php | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/service/filesservice.php b/service/filesservice.php index 5527fc94e4..a2d81a1d57 100644 --- a/service/filesservice.php +++ b/service/filesservice.php @@ -106,9 +106,11 @@ protected function getNodes($folder, $subDepth) { } /** - * Determines if the files are hosted locally (shared or not) + * Determines if the files are hosted locally (shared or not) and can be used by the preview + * system * - * isMounted() includes externally hosted shares, so we need to exclude those + * isMounted() includes externally hosted shares (s2s) and locally mounted shares, so we need + * to exclude those * * @param Node $node * @@ -117,7 +119,7 @@ protected function getNodes($folder, $subDepth) { protected function isLocalAndAvailable($node) { try { if (!$node->isMounted()) { - return !$this->isExternalShare($node) && $node->isReadable(); + return $this->isLocal($node) && $this->isAvailable($node); } } catch (\Exception $exception) { $message = 'The folder is not available: ' . $exception->getMessage(); @@ -262,6 +264,33 @@ private function recoverFromGetNodesError($subDepth, $exception) { return []; } + /** + * Determines if we can consider the node mounted locally or if it's been authorised to be + * scanned + * + * @param Node $node + * + * @return bool + */ + private function isLocal($node) { + $mount = $node->getMountPoint(); + + return !$this->isExternalShare($node) && $mount && $mount->getOption('previews', true); + } + + /** + * Determines if the node is available, as in readable + * + * @todo Test to see by how much using file_exists slows things down + * + * @param Node $node + * + * @return bool + */ + private function isAvailable($node) { + return $node->isReadable(); + } + /** * Determines if the node is a share which is hosted externally *