diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php index 7a137cb3f5..b7e3321b80 100644 --- a/apps/gallery/lib/scanner.php +++ b/apps/gallery/lib/scanner.php @@ -97,18 +97,18 @@ class OC_Gallery_Scanner { foreach ($a as $e) { $p .= ($p == '/'?'':'/').$e; OC_Gallery_Album::create(OCP\USER::getUser(), $e, $p); - $arr = OC_FileCache::searchByMime('image','', OC_Filesystem::getRoot().$p); - $step = floor(count($arr)/10); - if ($step == 0) $step = 1; - $na = array(); - for ($j = 0; $j < count($arr); $j+=$step) { - $na[] = $p.$arr[$j]; - } - if (count($na)) - self::createThumbnails($e, $na); + $arr = OC_FileCache::searchByMime('image','', OC_Filesystem::getRoot().$p); + $step = floor(count($arr)/10); + if ($step == 0) $step = 1; + $na = array(); + for ($j = 0; $j < count($arr); $j+=$step) { + $na[] = $p.$arr[$j]; + } + if (count($na)) + self::createThumbnails($e, $na); } } - } + } } } @@ -126,19 +126,25 @@ class OC_Gallery_Scanner { return $new; } - public static function findPaths() { - $images=OC_FileCache::searchByMime('image','', self::getScanningRoot()); - $paths=array(); - foreach($images as $image){ - $path=dirname($image); - $path = self::getGalleryRoot().($path=='.'?'':$path); - if ($path !== '/') $path=rtrim($path,'/'); - if(array_search($path,$paths)===false){ - $paths[]=$path; - } - } - sort($paths); - return $paths; + public static function findPaths() { + $images=OC_FileCache::searchByMime('image','', self::getScanningRoot()); + $paths=array(); + foreach($images as $image){ + $path=dirname($image); + $path = self::getGalleryRoot().($path=='.'?'':$path); + if ($path !== '/') $path=rtrim($path,'/'); + if(array_search($path,$paths)===false){ + $paths[]=$path; + } + // add sub path also if they don't contain images + while ( ($path = dirname($path)) != '/') { + if(array_search($path,$paths)===false){ + $paths[]=$path; + } + } + $subs = dirname($path); + } + sort($paths); + return $paths; } } -