CC-2558 : Only delete files from disk that are in stor directory and not scheduled etc.
This commit is contained in:
parent
b7819211ac
commit
c7279f74ca
|
@ -63,12 +63,15 @@ class LibraryController extends Zend_Controller_Action
|
||||||
$paramsPop = str_replace('#id#', $id, $params);
|
$paramsPop = str_replace('#id#', $id, $params);
|
||||||
$paramsPop = str_replace('#type#', $type, $paramsPop);
|
$paramsPop = str_replace('#type#', $type, $paramsPop);
|
||||||
|
|
||||||
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
|
$user = new User($userInfo->id);
|
||||||
|
|
||||||
$pl_sess = $this->pl_sess;
|
$pl_sess = $this->pl_sess;
|
||||||
|
|
||||||
if($type === "au") {
|
if($type === "au") {
|
||||||
|
|
||||||
if(isset($pl_sess->id)) {
|
if(isset($pl_sess->id)) {
|
||||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Playlist/add-item'.$params, 'callback' => 'window["setSPLContent"]'),
|
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Playlist/add-item'.$params, 'callback' => 'window["setSPLContent"]'),
|
||||||
'title' => 'Add to Playlist');
|
'title' => 'Add to Playlist');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,9 +88,12 @@ class LibraryController extends Zend_Controller_Action
|
||||||
$menu[] = array('action' => array('type' => 'gourl', 'url' => $url),
|
$menu[] = array('action' => array('type' => 'gourl', 'url' => $url),
|
||||||
'title' => 'Download');
|
'title' => 'Download');
|
||||||
|
|
||||||
$menu[] = array('action' => array('type' => 'fn',
|
|
||||||
'callback' => "window['confirmDeleteAudioClip']('$paramsPop')"),
|
if ($user->isAdmin()) {
|
||||||
'title' => 'Delete');
|
$menu[] = array('action' => array('type' => 'fn',
|
||||||
|
'callback' => "window['confirmDeleteAudioClip']('$paramsPop')"),
|
||||||
|
'title' => 'Delete');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if($type === "pl") {
|
else if($type === "pl") {
|
||||||
|
|
||||||
|
@ -121,32 +127,37 @@ class LibraryController extends Zend_Controller_Action
|
||||||
public function deleteAction()
|
public function deleteAction()
|
||||||
{
|
{
|
||||||
$id = $this->_getParam('id');
|
$id = $this->_getParam('id');
|
||||||
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
|
$user = new User($userInfo->id);
|
||||||
|
|
||||||
if (!is_null($id)) {
|
if ($user->isAdmin()) {
|
||||||
$file = StoredFile::Recall($id);
|
|
||||||
|
|
||||||
if (PEAR::isError($file)) {
|
if (!is_null($id)) {
|
||||||
$this->view->message = $file->getMessage();
|
$file = StoredFile::Recall($id);
|
||||||
return;
|
|
||||||
}
|
if (PEAR::isError($file)) {
|
||||||
else if(is_null($file)) {
|
$this->view->message = $file->getMessage();
|
||||||
$this->view->message = "file doesn't exist";
|
return;
|
||||||
return;
|
}
|
||||||
|
else if(is_null($file)) {
|
||||||
|
$this->view->message = "file doesn't exist";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = $file->delete();
|
||||||
|
|
||||||
|
if (PEAR::isError($res)) {
|
||||||
|
$this->view->message = $res->getMessage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$data = array("filepath" => $file->getFilePath(), "delete" => $res);
|
||||||
|
RabbitMq::SendMessageToMediaMonitor("file_delete", $data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $file->delete();
|
$this->view->id = $id;
|
||||||
|
|
||||||
if (PEAR::isError($res)) {
|
|
||||||
$this->view->message = $res->getMessage();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$data = array("filepath" => $file->getFilePath(), "delete" => $res);
|
|
||||||
RabbitMq::SendMessageToMediaMonitor("file_delete", $data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->view->id = $id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function contentsAction()
|
public function contentsAction()
|
||||||
|
|
|
@ -123,9 +123,10 @@ class PreferenceController extends Zend_Controller_Action
|
||||||
$chosen = $this->getRequest()->getParam("dir");
|
$chosen = $this->getRequest()->getParam("dir");
|
||||||
$element = $this->getRequest()->getParam("element");
|
$element = $this->getRequest()->getParam("element");
|
||||||
$watched_dirs_form = new Application_Form_WatchedDirPreferences();
|
$watched_dirs_form = new Application_Form_WatchedDirPreferences();
|
||||||
$watched_dirs_form->populate(array('storageFolder' => $chosen));
|
|
||||||
$res = MusicDir::setStorDir($chosen);
|
$res = MusicDir::setStorDir($chosen);
|
||||||
if($res['code'] != 0){
|
if($res['code'] != 0){
|
||||||
|
$watched_dirs_form->populate(array('storageFolder' => $chosen));
|
||||||
$watched_dirs_form->getElement($element)->setErrors(array($res['error']));
|
$watched_dirs_form->getElement($element)->setErrors(array($res['error']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,9 +138,10 @@ class PreferenceController extends Zend_Controller_Action
|
||||||
$chosen = $this->getRequest()->getParam("dir");
|
$chosen = $this->getRequest()->getParam("dir");
|
||||||
$element = $this->getRequest()->getParam("element");
|
$element = $this->getRequest()->getParam("element");
|
||||||
$watched_dirs_form = new Application_Form_WatchedDirPreferences();
|
$watched_dirs_form = new Application_Form_WatchedDirPreferences();
|
||||||
$watched_dirs_form->populate(array('watchedFolder' => $chosen));
|
|
||||||
$res = MusicDir::addWatchedDir($chosen);
|
$res = MusicDir::addWatchedDir($chosen);
|
||||||
if($res['code'] != 0){
|
if($res['code'] != 0){
|
||||||
|
$watched_dirs_form->populate(array('watchedFolder' => $chosen));
|
||||||
$watched_dirs_form->getElement($element)->setErrors(array($res['error']));
|
$watched_dirs_form->getElement($element)->setErrors(array($res['error']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,23 @@ class MusicDir {
|
||||||
|
|
||||||
public function remove()
|
public function remove()
|
||||||
{
|
{
|
||||||
|
global $CC_DBC;
|
||||||
|
|
||||||
|
$music_dir_id = $this->getId();
|
||||||
|
|
||||||
|
$sql = "SELECT DISTINCT s.instance_id from cc_music_dirs as md LEFT JOIN cc_files as f on f.directory = md.id
|
||||||
|
RIGHT JOIN cc_schedule as s on s.file_id = f.id WHERE md.id = $music_dir_id";
|
||||||
|
|
||||||
|
$show_instances = $CC_DBC->GetAll($sql);
|
||||||
|
|
||||||
$this->_dir->delete();
|
$this->_dir->delete();
|
||||||
|
|
||||||
|
foreach ($show_instances as $show_instance_row) {
|
||||||
|
$temp_show = new ShowInstance($show_instance_row["instance_id"]);
|
||||||
|
$temp_show->updateScheduledTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function addDir($p_path, $p_type)
|
public static function addDir($p_path, $p_type)
|
||||||
|
|
|
@ -341,18 +341,7 @@ class StoredFile {
|
||||||
return PEAR::raiseError('Cannot delete a file that is scheduled in the future.');
|
return PEAR::raiseError('Cannot delete a file that is scheduled in the future.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$storageDir = MusicDir::getStorDir()->getDirectory();
|
return true;
|
||||||
$dirCompare = substr($this->getFilePath(), 0, strlen($storageDir));
|
|
||||||
|
|
||||||
//return PEAR::raiseError("({$storageDir} , {$dirCompare})");
|
|
||||||
|
|
||||||
// Only delete the file from filesystem if it has been copied to the storage directory
|
|
||||||
if ($dirCompare === $storageDir) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -35,7 +35,7 @@ function deleteAudioClip(json) {
|
||||||
|
|
||||||
//callbacks called by jjmenu
|
//callbacks called by jjmenu
|
||||||
function confirmDeleteAudioClip(params){
|
function confirmDeleteAudioClip(params){
|
||||||
if(confirm('Are you sure you want to delete?')){
|
if(confirm('The file will be deleted from disk, are you sure you want to delete?')){
|
||||||
var url = '/Library/delete' + params;
|
var url = '/Library/delete' + params;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
|
|
|
@ -57,6 +57,9 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
#file created is a tmp file which will be modified and then moved back to the original filename.
|
#file created is a tmp file which will be modified and then moved back to the original filename.
|
||||||
#Easy Tag creates this when changing metadata of ogg files.
|
#Easy Tag creates this when changing metadata of ogg files.
|
||||||
self.temp_files[pathname] = None
|
self.temp_files[pathname] = None
|
||||||
|
#file is being overwritten/replaced in GUI.
|
||||||
|
elif "goutputstream" in pathname:
|
||||||
|
self.temp_files[pathname] = None
|
||||||
elif self.mmc.is_audio_file(pathname):
|
elif self.mmc.is_audio_file(pathname):
|
||||||
if self.mmc.is_parent_directory(pathname, self.config.organize_directory):
|
if self.mmc.is_parent_directory(pathname, self.config.organize_directory):
|
||||||
#file was created in /srv/airtime/stor/organize. Need to process and move
|
#file was created in /srv/airtime/stor/organize. Need to process and move
|
||||||
|
|
Loading…
Reference in New Issue