SAAS-382: Reimplement Storage Quota

Storing disk usage in cc_pref
Add/subtract filesize to/from disk usage total when a file is uploaded or deleted
TODO: Hook this into the ftp server
This commit is contained in:
drigato 2014-03-21 09:50:03 -04:00
parent 2b696dbee5
commit 7800cb1e15
3 changed files with 25 additions and 1 deletions

View file

@ -156,7 +156,8 @@ class Rest_MediaController extends Zend_Rest_Controller
//our internal schema. Internally, file path is stored relative to a directory, with the directory
//as a foreign key to cc_music_dirs.
if ($requestData["full_path"]) {
Application_Model_Preference::updateDiskUsage(filesize($requestData["full_path"]));
$fullPath = $requestData["full_path"];
$storDir = Application_Model_MusicDir::getStorDir()->getDirectory();
$pos = strpos($fullPath, $storDir);
@ -196,6 +197,7 @@ class Rest_MediaController extends Zend_Rest_Controller
$file = CcFilesQuery::create()->findPk($id);
if ($file) {
$storedFile = Application_Model_StoredFile($file);
Application_Model_Preference::updateDiskUsage(-1 * abs(filesize($storedFile->getFilePath())));
$storedFile->delete(); //TODO: This checks your session permissions... Make it work without a session?
$file->delete();
$this->getResponse()
@ -373,5 +375,6 @@ class Rest_MediaController extends Zend_Rest_Controller
return $response;
}
}