fix for bug #872: Folders not holding any images are ignored, even if they hold subfolders with images

remotes/origin/stable4
Bjoern Schiessle 13 years ago
parent a7a861b2c6
commit 0722ff6e32
  1. 54
      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;
}
}

Loading…
Cancel
Save