check for user count and files count

This commit is contained in:
Morris Jobke 2014-06-03 11:39:16 +02:00
parent 68a4fd44e6
commit f88482355f

View file

@ -89,9 +89,28 @@ foreach($forms as $form) {
$tmpl->append('forms', $form);
}
// TODO - replace by:
// > 5 users OR > 1000 files
$tmpl->assign('databaseOverload', true);
$databaseOverload = false;
if(strpos(\OCP\Config::getSystemValue('dbtype'), 'sqlite') !== false){
// > 5 users
$userCount = 0;
foreach (\OC::$server->getUserManager()->countUsers() as $classname => $count) {
$userCount += $count;
}
if($userCount >= 5){
$databaseOverload = true;
}
// OR > 1000 files
$sql = 'SELECT COUNT(*) FROM *PREFIX*filecache;';
$query = \OCP\DB::prepare($sql);
$row = $query->execute()->fetchRow();
$fileCount = $row['COUNT(*)'];
if($fileCount >= 1000){
$databaseOverload = true;
}
}
$tmpl->assign('databaseOverload', $databaseOverload);
$tmpl->printPage();