CC-3634: Media Folder: if file was deleted from file system, and the file was

scheduled in the future, it wasn't getting deleted from AIrtime

- fixed
This commit is contained in:
James 2012-04-12 16:17:19 -04:00
parent 4ef18fb00f
commit 53e37ee826
3 changed files with 30 additions and 6 deletions

View File

@ -648,13 +648,13 @@ class ApiController extends Zend_Controller_Action
$filepath = $md['MDATA_KEY_FILEPATH'];
$filepath = str_replace("\\", "", $filepath);
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
if (is_null($file)) {
$this->view->error = "File doesn't exist in Airtime.";
return;
}
else {
$file->delete();
$file->deleteByMediaMonitor();
}
}
else if ($mode == "delete_dir") {
@ -663,7 +663,7 @@ class ApiController extends Zend_Controller_Action
$files = Application_Model_StoredFile::RecallByPartialFilepath($filepath);
foreach($files as $file){
$file->delete();
$file->deleteByMediaMonitor();
}
return;
}

View File

@ -578,6 +578,11 @@ class Application_Model_Schedule {
global $CC_CONFIG, $CC_DBC;
$CC_DBC->query("TRUNCATE TABLE ".$CC_CONFIG["scheduleTable"]);
}
public static function deleteWithFileId($fileId){
global $CC_CONFIG, $CC_DBC;
$CC_DBC->query("DELETE FROM ".$CC_CONFIG["scheduleTable"]." WHERE file_id=$fileId");
}
public static function createNewFormSections($p_view){
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;

View File

@ -286,14 +286,12 @@ class Application_Model_StoredFile {
{
$filepath = $this->getFilePath();
// Check if the file is scheduled to be played in the future
if (Application_Model_Schedule::IsFileScheduledInTheFuture($this->getId())) {
throw new DeleteScheduledFileException();
}
if (file_exists($filepath)) {
$data = array("filepath" => $filepath, "delete" => 1);
Application_Model_RabbitMq::SendMessageToMediaMonitor("file_delete", $data);
}
@ -301,11 +299,32 @@ class Application_Model_StoredFile {
if ($deleteFromPlaylist){
Application_Model_Playlist::DeleteFileFromAllPlaylists($this->getId());
}
// set file_exists falg to false
$this->_file->setDbFileExists(false);
$this->_file->save();
}
/**
* This function is for when media monitor detects deletion of file
* and trying to update airtime side
*
* @param boolean $p_deleteFile
*
*/
public function deleteByMediaMonitor($deleteFromPlaylist=false)
{
$filepath = $this->getFilePath();
if ($deleteFromPlaylist){
Application_Model_Playlist::DeleteFileFromAllPlaylists($this->getId());
}
// set file_exists falg to false
$this->_file->setDbFileExists(false);
$this->_file->save();
// delete entries in cc_schedule which has file_id as this file
Application_Model_Schedule::deleteWithFileId(self::getId());
}
/**
* Return suitable extension.