]> source.dussan.org Git - nextcloud-server.git/commitdiff
change gallary scanning to support gallaries inside archives
authorRobin Appelman <icewind@owncloud.com>
Sat, 3 Mar 2012 21:04:34 +0000 (22:04 +0100)
committerRobin Appelman <icewind@owncloud.com>
Sat, 3 Mar 2012 21:04:34 +0000 (22:04 +0100)
apps/gallery/ajax/galleryOp.php
apps/gallery/js/album_cover.js
apps/gallery/lib/scanner.php

index f07814056a307bf3dfd8281dfedd97192ca7b95e..c19344c0fbbd8ceb1ede356e4fc5bc032e29ea51 100644 (file)
@@ -62,7 +62,7 @@ function handleFilescan($cleanup) {
 
 function handlePartialCreate($path) {
   if (empty($path)) OC_JSON::error(array('cause' => 'No path specified'));
-  if (!OC_Filesystem::is_dir($path)) OC_JSON::error(array('cause' => 'Invalid path given'));
+  if (!OC_Filesystem::is_dir($path.'/')) OC_JSON::error(array('cause' => 'Invalid path given'));
 
   $album = OC_Gallery_Album::find(OC_User::getUser(), null, $path);
   $albums = array();
index 4ddac2f211131c379a50c6a095a554c128ee7881..d328a2d58e57eb6ed1c7bfe140a51b8f3f60d0ce 100644 (file)
@@ -53,7 +53,7 @@ function scanForAlbums(cleanup) {
       }
       $('#scanprogressbar').progressbar({ value: (albumCounter/totalAlbums)*100 }).fadeIn();
       for(var a in r.paths) {
-        $.getJSON('ajax/galleryOp.php?operation=partial_create&path='+r.paths[a], function(r) {
+                 $.getJSON('ajax/galleryOp.php',{operation:'partial_create','path':r.paths[a]}, function(r) {
 
           if (r.status == 'success') {
             Albums.add(r.album_details.albumName, r.album_details.imagesCount);
index 64efb006ad191bcef3a1977010258550295a67ce..9c381acf38995b915fcc0c9ea563263797bdff09 100644 (file)
@@ -53,7 +53,7 @@ class OC_Gallery_Scanner {
     $current_album = array('name'=> $path, 'imagesCount' => 0, 'images' => array());
     $current_album['name'] = self::createName($current_album['name']);
 
-    if ($dh = OC_Filesystem::opendir($path)) {
+    if ($dh = OC_Filesystem::opendir($path.'/')) {
       while (($filename = readdir($dh)) !== false) {
         $filepath = ($path[strlen($path)-1]=='/'?$path:$path.'/').$filename;
         if (substr($filename, 0, 1) == '.') continue;
@@ -103,21 +103,16 @@ class OC_Gallery_Scanner {
   }
 
   public static function find_paths($path) {
-    $ret = array();
-    $dirres;
-    $addpath = FALSE;
-    if (($dirres = OC_Filesystem::opendir($path)) == FALSE) return $ret;
-
-    while (($file = readdir($dirres)) != FALSE) {
-      if ($file[0] == '.') continue;
-      if (OC_Filesystem::is_dir($path.$file))
-        $ret = array_merge($ret, self::find_paths($path.$file.'/'));
-      if (self::isPhoto($path.$file)) $addpath = TRUE;
-    }
-
-    if ($addpath) $ret[] = urlencode($path);
-
-    return $ret;
+       $images=OC_FileCache::searchByMime('image');
+       $paths=array();
+       foreach($images as $image){
+               $path=dirname($image);
+               if(array_search($path,$paths)===false){
+                       error_log($path);
+                       $paths[]=$path;
+               }
+       }
+       return $paths;
   }
 }
 ?>