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 May 12, 2015
1 parent b01140f commit 9b4bb69
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions service/filesservice.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,20 @@ 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
*
* @return bool
*/
protected function isLocalAndAvailable($node) {
if (!$node->isMounted()) {
return !$this->isExternalShare($node) && $node->isReadable();

return $this->isLocal($node) && $this->isAvailable($node);
}

return false;
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit 9b4bb69

Please sign in to comment.