Compare commits

...

2 Commits

Author SHA1 Message Date
Robin Appelman 193407add0
switch method to detect if a directory is readable
Signed-off-by: Robin Appelman <robin@icewind.nl>
2019-11-15 13:47:57 +01:00
Robin Appelman 6c3a4a7106
Filter out folders that don't have read permissions on smb storages
Signed-off-by: Robin Appelman <robin@icewind.nl>
2019-11-13 13:57:15 +01:00
1 changed files with 17 additions and 2 deletions

View File

@ -131,7 +131,7 @@ class SMB extends Common implements INotifyStorage {
private function splitUser($user) {
if (strpos($user, '/')) {
return explode('/', $user, 2);
} elseif (strpos($user, '\\')) {
} else if (strpos($user, '\\')) {
return explode('\\', $user);
} else {
return [null, $user];
@ -199,6 +199,15 @@ class SMB extends Common implements INotifyStorage {
throw new StorageAuthException($e->getMessage(), $e);
}
protected function directoryIsReadable(string $path): bool {
try {
$this->share->dir($path);
} catch (ForbiddenException $e) {
return false;
}
return true;
}
/**
* @param string $path
* @return \Icewind\SMB\IFileInfo[]
@ -215,7 +224,13 @@ class SMB extends Common implements INotifyStorage {
try {
// the isHidden check is done before checking the config boolean to ensure that the metadata is always fetch
// so we trigger the below exceptions where applicable
$hide = $file->isHidden() && !$this->showHidden;
$hidden = $file->isHidden();
if ($file->isDirectory() && !$hidden) {
$hidden = !$this->directoryIsReadable($file->getPath());
}
$hide = !$this->showHidden && $hidden;
if ($hide) {
$this->logger->debug('hiding hidden file ' . $file->getName());
}