CC-5806: Airtime Analyzer: Please implement "remove all files"
This commit is contained in:
parent
04da9b3d61
commit
a5eb5e9901
|
@ -23,5 +23,15 @@ class Rest_Bootstrap extends Zend_Application_Module_Bootstrap
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$router->addRoute('download', $downloadRoute);
|
$router->addRoute('download', $downloadRoute);
|
||||||
|
|
||||||
|
$clearLibraryRoute = new Zend_Controller_Router_Route(
|
||||||
|
'rest/media/clear',
|
||||||
|
array(
|
||||||
|
'controller' => 'media',
|
||||||
|
'action' => 'clear',
|
||||||
|
'module' => 'rest'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$router->addRoute('clear', $clearLibraryRoute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,42 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
$this->fileNotFoundResponse();
|
$this->fileNotFoundResponse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function clearAction()
|
||||||
|
{
|
||||||
|
//TODO:: make this not accessible via public api??
|
||||||
|
if (!$this->verifyAuth(true, true))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//set file_exists flag to false for every file
|
||||||
|
$con = Propel::getConnection(CcFilesPeer::DATABASE_NAME);
|
||||||
|
$selectCriteria = new Criteria();
|
||||||
|
$selectCriteria->add(CcFilesPeer::FILE_EXISTS, true);
|
||||||
|
$updateCriteria = new Criteria();
|
||||||
|
$updateCriteria->add(CcFilesPeer::FILE_EXISTS, false);
|
||||||
|
BasePeer::doUpdate($selectCriteria, $updateCriteria, $con);
|
||||||
|
|
||||||
|
$path = isset($_SERVER['AIRTIME_BASE']) ? $_SERVER['AIRTIME_BASE']."/srv/airtime/stor/imported/*" : "/srv/airtime/stor/imported/*";
|
||||||
|
exec("rm -rf $path");
|
||||||
|
|
||||||
|
//update disk_usage value in cc_pref
|
||||||
|
$musicDir = CcMusicDirsQuery::create()
|
||||||
|
->filterByType('stor')
|
||||||
|
->filterByExists(true)
|
||||||
|
->findOne();
|
||||||
|
$storPath = $musicDir->getDirectory();
|
||||||
|
|
||||||
|
$freeSpace = disk_free_space($storPath);
|
||||||
|
$totalSpace = disk_total_space($storPath);
|
||||||
|
|
||||||
|
Application_Model_Preference::setDiskUsage($totalSpace - $freeSpace);
|
||||||
|
|
||||||
|
$this->getResponse()
|
||||||
|
->setHttpResponseCode(200)
|
||||||
|
->appendBody("Library has been cleared");
|
||||||
|
}
|
||||||
|
|
||||||
public function getAction()
|
public function getAction()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue