From 333ab1b089666620b4391dbe3a8d6f2bc7588adc 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 | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/service/filesservice.php b/service/filesservice.php index 782dad750f..d6fe4c919a 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 * @@ -116,7 +118,8 @@ protected function getNodes($folder, $subDepth) { */ protected function isLocalAndAvailable($node) { if (!$node->isMounted()) { - return !$this->isExternalShare($node) && $node->isReadable(); + + return $this->isLocal($node) && $this->isAvailable($node); } return false; @@ -256,6 +259,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 *