diff options
author | Brice Maron <brice@bmaron.net> | 2012-06-24 19:41:23 +0000 |
---|---|---|
committer | Brice Maron <brice@bmaron.net> | 2012-06-24 19:41:23 +0000 |
commit | 61adae1e49b67cfe79d5daf2bc9e649b343090bb (patch) | |
tree | 488e342b289cdc5b2a2ef06b1723e61bfb4ce2c2 /apps/media | |
parent | f56b3df0bcb2c678b944f5086adad6e3e678252a (diff) | |
download | nextcloud-server-61adae1e49b67cfe79d5daf2bc9e649b343090bb.tar.gz nextcloud-server-61adae1e49b67cfe79d5daf2bc9e649b343090bb.zip |
Use intervals for sessions deletion with postgres fix oc-492
Diffstat (limited to 'apps/media')
-rw-r--r-- | apps/media/lib_ampache.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/apps/media/lib_ampache.php b/apps/media/lib_ampache.php index f5c91661abe..255e6f468f8 100644 --- a/apps/media/lib_ampache.php +++ b/apps/media/lib_ampache.php @@ -77,7 +77,7 @@ class OC_MEDIA_AMPACHE{ $songs=OC_MEDIA_COLLECTION::getSongCount(); $artists=OC_MEDIA_COLLECTION::getArtistCount(); $albums=OC_MEDIA_COLLECTION::getAlbumCount(); - $query=OCP\DB::prepare("INSERT INTO *PREFIX*media_sessions (`session_id`, `token`, `user_id`, `start`) VALUES (NULL, ?, ?, now());"); + $query=OCP\DB::prepare("INSERT INTO *PREFIX*media_sessions (`token`, `user_id`, `start`) VALUES (?, ?, now());"); $query->execute(array($token,$user)); $expire=date('c',time()+600); echo('<?xml version="1.0" encoding="UTF-8"?>'); @@ -136,8 +136,14 @@ class OC_MEDIA_AMPACHE{ return false; } } + $CONFIG_DBTYPE = OCP\Config::getSystemValue( "dbtype", "sqlite" ); + if($CONFIG_DBTYPE == 'psql'){ + $interval = ' \'600s\'::interval '; + }else { + $interval = '600'; + } //remove old sessions - $query=OCP\DB::prepare("DELETE from *PREFIX*media_sessions WHERE start<(NOW()-600)"); + $query=OCP\DB::prepare("DELETE from *PREFIX*media_sessions WHERE start<(NOW() - ".$interval.")"); $query->execute(); $query=OCP\DB::prepare("SELECT user_id from *PREFIX*media_sessions WHERE token=?"); |