[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [owncloud] apps/media/ajax: cache the media collection between page
From: Robin Appelman <icewind1991 () gmail ! com>
Date: 2011-07-31 22:18:14
Message-ID: 20110731221814.1CC70A60A6 () git ! kde ! org
[Download RAW message or body]
Git commit bd6b38e6383488ab1a84261c63856adac2e215dd by Robin Appelman.
Committed on 01/08/2011 at 00:18.
Pushed by rappelman into branch 'master'.
cache the media collection between page loads
M +13 -7 apps/media/ajax/api.php
http://commits.kde.org/owncloud/bd6b38e6383488ab1a84261c63856adac2e215dd
diff --git a/apps/media/ajax/api.php b/apps/media/ajax/api.php
index bb86c13..b888316 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':
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic