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,6 +63,9 @@ 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") {
|
||||||
|
@ -85,10 +88,13 @@ 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');
|
||||||
|
|
||||||
|
|
||||||
|
if ($user->isAdmin()) {
|
||||||
$menu[] = array('action' => array('type' => 'fn',
|
$menu[] = array('action' => array('type' => 'fn',
|
||||||
'callback' => "window['confirmDeleteAudioClip']('$paramsPop')"),
|
'callback' => "window['confirmDeleteAudioClip']('$paramsPop')"),
|
||||||
'title' => 'Delete');
|
'title' => 'Delete');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if($type === "pl") {
|
else if($type === "pl") {
|
||||||
|
|
||||||
if(!isset($pl_sess->id) || $pl_sess->id !== $id) {
|
if(!isset($pl_sess->id) || $pl_sess->id !== $id) {
|
||||||
|
@ -121,6 +127,10 @@ 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 ($user->isAdmin()) {
|
||||||
|
|
||||||
if (!is_null($id)) {
|
if (!is_null($id)) {
|
||||||
$file = StoredFile::Recall($id);
|
$file = StoredFile::Recall($id);
|
||||||
|
@ -148,6 +158,7 @@ class LibraryController extends Zend_Controller_Action
|
||||||
|
|
||||||
$this->view->id = $id;
|
$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,19 +341,8 @@ 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();
|
|
||||||
$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;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if media file exists
|
* Returns true if media file exists
|
||||||
|
|
|
@ -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