summaryrefslogtreecommitdiffstats
path: root/apps/media/ajax
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-08-01 00:18:09 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-08-01 00:18:09 +0200
commitbd6b38e6383488ab1a84261c63856adac2e215dd (patch)
tree4f77d2c805812ca764a366c76f97f29db5982698 /apps/media/ajax
parent2d199657506a53dda1bd2879f951684c26133ff2 (diff)
downloadnextcloud-server-bd6b38e6383488ab1a84261c63856adac2e215dd.tar.gz
nextcloud-server-bd6b38e6383488ab1a84261c63856adac2e215dd.zip
cache the media collection between page loads
Diffstat (limited to 'apps/media/ajax')
-rw-r--r--apps/media/ajax/api.php20
1 files changed, 13 insertions, 7 deletions
diff --git a/apps/media/ajax/api.php b/apps/media/ajax/api.php
index bb86c13f287..b8883166732 100644
--- a/apps/media/ajax/api.php
+++ b/apps/media/ajax/api.php
@@ -56,6 +56,7 @@ OC_MEDIA_COLLECTION::$uid=OC_User::getUser();
if($arguments['action']){
switch($arguments['action']){
case 'delete':
+ unset($_SESSION['collection']);
$path=$arguments['path'];
OC_MEDIA_COLLECTION::deleteSongByPath($path);
$paths=explode(PATH_SEPARATOR,OC_Preferences::getValue(OC_User::getUser(),'media','paths',''));
@@ -64,17 +65,21 @@ if($arguments['action']){
OC_Preferences::setValue(OC_User::getUser(),'media','paths',implode(PATH_SEPARATOR,$paths));
}
case 'get_collection':
- $artists=OC_MEDIA_COLLECTION::getArtists();
- foreach($artists as &$artist){
- $artist['albums']=OC_MEDIA_COLLECTION::getAlbums($artist['artist_id']);
- foreach($artist['albums'] as &$album){
- $album['songs']=OC_MEDIA_COLLECTION::getSongs($artist['artist_id'],$album['album_id']);
+ if(!isset($_SESSION['collection'])){
+ $artists=OC_MEDIA_COLLECTION::getArtists();
+ foreach($artists as &$artist){
+ $artist['albums']=OC_MEDIA_COLLECTION::getAlbums($artist['artist_id']);
+ foreach($artist['albums'] as &$album){
+ $album['songs']=OC_MEDIA_COLLECTION::getSongs($artist['artist_id'],$album['album_id']);
+ }
}
+
+ $_SESSION['collection']=json_encode($artists);
}
-
- echo json_encode($artists);
+ echo $_SESSION['collection'];
break;
case 'scan':
+ unset($_SESSION['collection']);
OC_DB::beginTransaction();
set_time_limit(0); //recursive scan can take a while
$path=$arguments['path'];
@@ -90,6 +95,7 @@ if($arguments['action']){
flush();
break;
case 'scanFile':
+ unset($_SESSION['collection']);
echo (OC_MEDIA_SCANNER::scanFile($arguments['path']))?'true':'false';
break;
case 'get_artists':