Merge branch 'cc-5709-airtime-analyzer' into saas

Conflicts:
	airtime_mvc/application/models/StoredFile.php
This commit is contained in:
Albert Santoni 2014-11-18 18:18:44 -05:00
commit 755df62a00

View file

@ -371,8 +371,6 @@ SQL;
*/ */
public function delete() public function delete()
{ {
$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();
@ -390,20 +388,21 @@ SQL;
assert($music_dir); assert($music_dir);
$type = $music_dir->getType(); $type = $music_dir->getType();
if (file_exists($filepath) && $type == "stor") { Logging::info($_SERVER["HTTP_HOST"].": User ".$user->getLogin()." is deleting file: ".$this->_file->getDbTrackTitle()." - file id: ".$this->_file->getDbId());
try {
try {
if ($this->existsOnDisk() && $type == "stor") {
$filepath = $this->getFilePath();
//Update the user's disk usage //Update the user's disk usage
Application_Model_Preference::updateDiskUsage(-1 * abs(filesize($filepath))); Application_Model_Preference::updateDiskUsage(-1 * abs(filesize($filepath)));
unlink($filepath); unlink($filepath);
} catch (Exception $e) {
Logging::error($e->getMessage());
return;
} }
} catch (Exception $e) {
Logging::warning($e->getMessage());
//If the file didn't exist on disk, that's fine, we still want to
//remove it from the database, so we continue here.
} }
Logging::info($_SERVER["HTTP_HOST"].": User ".$user->getLogin()." is deleting file: ".$this->_file->getDbTrackTitle()." - file id: ".$this->_file->getDbId());
// need to explicitly update any playlist's and block's length // need to explicitly update any playlist's and block's length
// that contains the file getting deleted // that contains the file getting deleted
$fileId = $this->_file->getDbId(); $fileId = $this->_file->getDbId();
@ -421,8 +420,7 @@ SQL;
$bl->save(); $bl->save();
} }
// We were setting file_exists to false and leaving it at that //We actually do want to delete the file from the database here
// but we should actually delete the file
$this->_file->delete(); $this->_file->delete();
} }