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:
parent
4ef18fb00f
commit
53e37ee826
|
@ -648,13 +648,13 @@ class ApiController extends Zend_Controller_Action
|
||||||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||||
$filepath = str_replace("\\", "", $filepath);
|
$filepath = str_replace("\\", "", $filepath);
|
||||||
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
|
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
|
||||||
|
|
||||||
if (is_null($file)) {
|
if (is_null($file)) {
|
||||||
$this->view->error = "File doesn't exist in Airtime.";
|
$this->view->error = "File doesn't exist in Airtime.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$file->delete();
|
$file->deleteByMediaMonitor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ($mode == "delete_dir") {
|
else if ($mode == "delete_dir") {
|
||||||
|
@ -663,7 +663,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
$files = Application_Model_StoredFile::RecallByPartialFilepath($filepath);
|
$files = Application_Model_StoredFile::RecallByPartialFilepath($filepath);
|
||||||
|
|
||||||
foreach($files as $file){
|
foreach($files as $file){
|
||||||
$file->delete();
|
$file->deleteByMediaMonitor();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -578,6 +578,11 @@ class Application_Model_Schedule {
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
$CC_DBC->query("TRUNCATE TABLE ".$CC_CONFIG["scheduleTable"]);
|
$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){
|
public static function createNewFormSections($p_view){
|
||||||
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
||||||
|
|
|
@ -286,14 +286,12 @@ class Application_Model_StoredFile {
|
||||||
{
|
{
|
||||||
|
|
||||||
$filepath = $this->getFilePath();
|
$filepath = $this->getFilePath();
|
||||||
|
|
||||||
// Check if the file is scheduled to be played in the future
|
// Check if the file is scheduled to be played in the future
|
||||||
if (Application_Model_Schedule::IsFileScheduledInTheFuture($this->getId())) {
|
if (Application_Model_Schedule::IsFileScheduledInTheFuture($this->getId())) {
|
||||||
throw new DeleteScheduledFileException();
|
throw new DeleteScheduledFileException();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($filepath)) {
|
if (file_exists($filepath)) {
|
||||||
|
|
||||||
$data = array("filepath" => $filepath, "delete" => 1);
|
$data = array("filepath" => $filepath, "delete" => 1);
|
||||||
Application_Model_RabbitMq::SendMessageToMediaMonitor("file_delete", $data);
|
Application_Model_RabbitMq::SendMessageToMediaMonitor("file_delete", $data);
|
||||||
}
|
}
|
||||||
|
@ -301,11 +299,32 @@ class Application_Model_StoredFile {
|
||||||
if ($deleteFromPlaylist){
|
if ($deleteFromPlaylist){
|
||||||
Application_Model_Playlist::DeleteFileFromAllPlaylists($this->getId());
|
Application_Model_Playlist::DeleteFileFromAllPlaylists($this->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// set file_exists falg to false
|
// set file_exists falg to false
|
||||||
$this->_file->setDbFileExists(false);
|
$this->_file->setDbFileExists(false);
|
||||||
$this->_file->save();
|
$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.
|
* Return suitable extension.
|
||||||
|
|
Loading…
Reference in New Issue