->setFlag(DefinitionParameter::FLAG_OPTIONAL),
(new DefinitionParameter('domain', $l->t('Domain')))
->setFlag(DefinitionParameter::FLAG_OPTIONAL),
+ (new DefinitionParameter('show_hidden', $l->t('Show hidden files')))
+ ->setType(DefinitionParameter::VALUE_BOOLEAN)
+ ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
])
->addAuthScheme(AuthMechanism::SCHEME_PASSWORD)
->addAuthScheme(AuthMechanism::SCHEME_SMB)
/** @var ILogger */
protected $logger;
+ /** @var bool */
+ protected $showHidden;
+
public function __construct($params) {
if (!isset($params['host'])) {
throw new \Exception('Invalid configuration, no host provided');
$this->root = '/' . ltrim($this->root, '/');
$this->root = rtrim($this->root, '/') . '/';
+ $this->showHidden = isset($params['show_hidden']) && $params['show_hidden'];
+
$this->statCache = new CappedMemoryCache();
parent::__construct($params);
}
}
return array_filter($files, function (IFileInfo $file) {
try {
- if ($file->isHidden()) {
+ // 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;
+ if ($hide) {
$this->logger->debug('hiding hidden file ' . $file->getName());
}
- return !$file->isHidden();
+ return !$hide;
} catch (ForbiddenException $e) {
$this->logger->logException($e, ['level' => ILogger::DEBUG, 'message' => 'Hiding forbidden entry ' . $file->getName()]);
return false;
public function isReadable($path) {
try {
$info = $this->getFileInfo($path);
- return !$info->isHidden();
+ return $this->showHidden || !$info->isHidden();
} catch (NotFoundException $e) {
return false;
} catch (ForbiddenException $e) {
$info = $this->getFileInfo($path);
// following windows behaviour for read-only folders: they can be written into
// (https://support.microsoft.com/en-us/kb/326549 - "cause" section)
- return !$info->isHidden() && (!$info->isReadOnly() || $this->is_dir($path));
+ return ($this->showHidden || !$info->isHidden()) && (!$info->isReadOnly() || $this->is_dir($path));
} catch (NotFoundException $e) {
return false;
} catch (ForbiddenException $e) {
public function isDeletable($path) {
try {
$info = $this->getFileInfo($path);
- return !$info->isHidden() && !$info->isReadOnly();
+ return ($this->showHidden || !$info->isHidden()) && !$info->isReadOnly();
} catch (NotFoundException $e) {
return false;
} catch (ForbiddenException $e) {