CC-5786: Quota Enforcement in the File Upload API
Tweaked this so it will work on self-hosted instances
This commit is contained in:
parent
4add0f0b7b
commit
63e2eda64b
|
@ -27,7 +27,7 @@ class PluploadController extends Zend_Controller_Action
|
|||
$this->view->headLink()->appendStylesheet($baseUrl.'css/addmedia.css?'.$CC_CONFIG['airtime_version']);
|
||||
|
||||
$this->view->quotaLimitReached = false;
|
||||
if (Application_Model_Preference::getDiskUsage() > Application_Model_Preference::getDiskQuota()) {
|
||||
if (Application_Model_Systemstatus::isDiskOverQuota()) {
|
||||
$this->view->quotaLimitReached = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -235,4 +235,16 @@ class Application_Model_Systemstatus
|
|||
|
||||
return array_values($partitions);
|
||||
}
|
||||
|
||||
public static function isDiskOverQuota()
|
||||
{
|
||||
$diskInfo = self::GetDiskInfo();
|
||||
$diskInfo = $diskInfo[0];
|
||||
$diskUsage = $diskInfo->totalSpace - $diskInfo->totalFreeSpace;
|
||||
if ($diskUsage > $diskInfo->totalSpace) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ class Rest_MediaController extends Zend_Rest_Controller
|
|||
return;
|
||||
}
|
||||
|
||||
if (!$this->isEnoughDiskSpace()) {
|
||||
if (!$this->isDiskOverQuota()) {
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(400)
|
||||
->appendBody("ERROR: Disk Quota limit reached.");
|
||||
|
@ -430,15 +430,9 @@ class Rest_MediaController extends Zend_Rest_Controller
|
|||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Checks if there is enough disk space to upload the file in question
|
||||
* We allow one file to exceed to the disk quota so it is possible for the
|
||||
* disk usage to be greater than the disk usage value
|
||||
*/
|
||||
private function isEnoughDiskSpace()
|
||||
private function isDiskOverQuota()
|
||||
{
|
||||
if (Application_Model_Preference::getDiskUsage() < Application_Model_Preference::GetDiskQuota()) {
|
||||
if (Application_Model_Systemstatus::isDiskOverQuota()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue