Skip to content

Commit

Permalink
Only allow locally mounted storage on which the preview system has be…
Browse files Browse the repository at this point in the history
…en enabled

Fixes #13
  • Loading branch information
oparoz committed Jun 26, 2015
1 parent 66898d9 commit 00abe89
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions service/filesservice.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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();
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit 00abe89

Please sign in to comment.