summaryrefslogtreecommitdiffstats
path: root/apps/media/ajax
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-02-08 17:30:16 +0100
committerRobin Appelman <icewind@owncloud.com>2012-02-08 17:30:16 +0100
commitc4a6b998146c29289794c1e15b71f1cfcfb4229a (patch)
treec1f1f6932798b7b4a8f6817240b1bf80064d2da1 /apps/media/ajax
parentbcebfbfbe229b5fdb1cfc1c058e11e78550ff088 (diff)
downloadnextcloud-server-c4a6b998146c29289794c1e15b71f1cfcfb4229a.tar.gz
nextcloud-server-c4a6b998146c29289794c1e15b71f1cfcfb4229a.zip
use oc_filecache and oc_eventsource for music scanning
Diffstat (limited to 'apps/media/ajax')
-rw-r--r--apps/media/ajax/api.php28
1 files changed, 4 insertions, 24 deletions
diff --git a/apps/media/ajax/api.php b/apps/media/ajax/api.php
index 4a93e84910e..ac6739a1386 100644
--- a/apps/media/ajax/api.php
+++ b/apps/media/ajax/api.php
@@ -70,10 +70,10 @@ if($arguments['action']){
case 'scan':
OC_DB::beginTransaction();
set_time_limit(0); //recursive scan can take a while
- $path=$arguments['path'];
- echo OC_MEDIA_SCANNER::scanFolder($path);
+ $eventSource=new OC_EventSource();
+ OC_MEDIA_SCANNER::scanCollection($eventSource);
+ $eventSource->close();
OC_DB::commit();
- flush();
break;
case 'scanFile':
echo (OC_MEDIA_SCANNER::scanFile($arguments['path']))?'true':'false';
@@ -127,29 +127,9 @@ if($arguments['action']){
OC_Filesystem::readfile($arguments['path']);
exit;
case 'find_music':
- OC_JSON::encodedPrint(findMusic());
+ OC_JSON::encodedPrint(OC_FileCache::searchByMime('audio'));
exit;
}
}
-function findMusic($path=''){
- $music=array();
- $dh=OC_Filesystem::opendir($path);
- if($dh){
- while($filename=readdir($dh)){
- if($filename[0]!='.'){
- $file=$path.'/'.$filename;
- if(OC_Filesystem::is_dir($file)){
- $music=array_merge($music,findMusic($file));
- }else{
- if(OC_MEDIA_SCANNER::isMusic($filename)){
- $music[]=$file;
- }
- }
- }
- }
- }
- return $music;
-}
-
?>