Skip to content
This repository was archived by the owner on Nov 1, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Gallery
# Gallery
[![Build Status](https://travis-ci.org/nextcloud/gallery.svg?branch=master)](https://travis-ci.org/nextcloud/gallery)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/nextcloud/gallery/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/nextcloud/gallery/?branch=master)
[![Code Coverage](https://codecov.io/gh/nextcloud/gallery/branch/master/graph/badge.svg)](https://codecov.io/gh/nextcloud/gallery)
Expand All @@ -20,7 +20,7 @@ Provides a dedicated view of all images in a grid, adds image viewing capabiliti
* A la carte features (external shares, browser svg rendering, etc.)
* Image download and sharing straight from the slideshow or the gallery
* Switch to Gallery from any folder in files and vice-versa
* Ignore folders containing a ".nomedia" file
* Ignore folders containing a ".nomedia" or ".noimage" file
* Browser rendering of SVG images (disabled by default)
* Mobile support

Expand Down
3 changes: 1 addition & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

- Switch to Gallery from any folder in files and vice-versa

- Ignore folders containing a ".nomedia" file
- Ignore folders containing a ".nomedia" or ".noimage" file

- Browser rendering of SVG images (disabled by default)

Expand Down Expand Up @@ -55,4 +55,3 @@
<developer>https://github.com/nextcloud/gallery/wiki</developer>
</documentation>
</info>

18 changes: 10 additions & 8 deletions lib/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function getSupportedMediaTypes($extraMediaTypes, $nativeSvgSupport) {
public function getConfig($folderNode, $features) {
$this->features = $features;
list ($albumConfig, $ignored) =
$this->collectConfig($folderNode, $this->ignoreAlbum, $this->configName);
$this->collectConfig($folderNode, $this->ignoreAlbumStrings, $this->configName);
if ($ignored) {
throw new ForbiddenServiceException(
'The owner has placed a restriction or the storage location is unavailable'
Expand Down Expand Up @@ -238,26 +238,28 @@ private function isMimeSupported($mimeType = '*') {
* reached the root folder
*
* @param Folder $folder the current folder
* @param string $ignoreAlbum name of the file which blacklists folders
* @param array $ignoreAlbumStrings names of the files which blacklist folders
* @param string $configName name of the configuration file
* @param int $level the starting level is 0 and we add 1 each time we visit a parent folder
* @param array $configSoFar the configuration collected so far
*
* @return array <null|array,bool>
*/
private function collectConfig(
$folder, $ignoreAlbum, $configName, $level = 0, $configSoFar = []
$folder, $ignoreAlbumStrings, $configName, $level = 0, $configSoFar = []
) {
if ($folder->nodeExists($ignoreAlbum)) {
// Cancel as soon as we find out that the folder is private or external
return [null, true];
foreach ($ignoreAlbumStrings as $ignoreAlbum) {
if ($folder->nodeExists($ignoreAlbum)) {
// Cancel as soon as we find out that the folder is private or external
return [null, true];
}
}
$isRootFolder = $this->isRootFolder($folder, $level);
if ($folder->nodeExists($configName)) {
$configSoFar = $this->buildFolderConfig($folder, $configName, $configSoFar, $level);
}
if (!$isRootFolder) {
return $this->getParentConfig($folder, $ignoreAlbum, $configName, $level, $configSoFar);
return $this->getParentConfig($folder, $ignoreAlbumStrings, $configName, $level, $configSoFar);
}
$configSoFar = $this->validatesInfoConfig($configSoFar);

Expand Down Expand Up @@ -345,7 +347,7 @@ private function validatesInfoConfig($albumConfig) {
* We will look up to the virtual root of a shared folder, for privacy reasons
*
* @param Folder $folder the current folder
* @param string $privacyChecker name of the file which blacklists folders
* @param string $privacyChecker names of the files which blacklist folders
* @param string $configName name of the configuration file
* @param int $level the starting level is 0 and we add 1 each time we visit a parent folder
* @param array $collectedConfig the configuration collected so far
Expand Down
11 changes: 7 additions & 4 deletions lib/Service/FilesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ abstract class FilesService extends Service {
protected $virtualRootLevel = null;
/** @var string[] */
protected $features;
/** @var string */
protected $ignoreAlbum = '.nomedia';
/** @var string[] */
protected $ignoreAlbumStrings = ['.nomedia', '.noimage'];

/**
* Retrieves all files and sub-folders contained in a folder
Expand Down Expand Up @@ -144,9 +144,12 @@ protected function getAllowedSubFolder($node, $nodeType) {
if ($nodeType === 'dir') {
/** @var Folder $node */
try {
if (!$node->nodeExists($this->ignoreAlbum)) {
return [$node];
foreach ($this->ignoreAlbumStrings as $ignoreAlbum) {
if ($node->nodeExists($ignoreAlbum)) {
return [];
}
}
return [$node];
} catch (StorageNotAvailableException $e) {
return [];
}
Expand Down