SAAS: Show logo is deleted on disk when a show instance is deleted

* Default to returning the station logo in response if we can't find the
  show logo on disk (but it's in our DB).
This commit is contained in:
Albert Santoni 2015-09-09 18:59:00 -04:00
parent 1f319f84a4
commit c77749a096
1 changed files with 13 additions and 4 deletions

View File

@ -416,17 +416,26 @@ class ApiController extends Zend_Controller_Action
} }
$path = $show->getDbImagePath(); $path = $show->getDbImagePath();
try {
$mime_type = mime_content_type($path); $mime_type = mime_content_type($path);
if (empty($path)) { if (empty($path)) {
throw new ZendActionHttpException($this, 400, "ERROR: Show does not have an associated image."); throw new ZendActionHttpException($this, 400, "ERROR: Show does not have an associated image.");
} }
} catch (Exception $e) {
//To avoid broken images on your site, we return the station logo if we can't find the show logo.
$this->_redirect('api/station-logo');
return;
}
try { try {
// Sometimes end users may be looking at stale data - if an image is removed // Sometimes end users may be looking at stale data - if an image is removed
// but has been cached in a client's browser this will throw an exception // but has been cached in a client's browser this will throw an exception
Application_Common_FileIO::smartReadFile($path, filesize($path), $mime_type); Application_Common_FileIO::smartReadFile($path, filesize($path), $mime_type);
} catch(FileNotFoundException $e) { } catch(FileNotFoundException $e) {
throw new ZendActionHttpException($this, 404, "ERROR: No image found at $path"); //throw new ZendActionHttpException($this, 404, "ERROR: No image found at $path");
$this->_redirect('api/station-logo');
return;
} catch(Exception $e) { } catch(Exception $e) {
throw new ZendActionHttpException($this, 500, "ERROR: " . $e->getMessage()); throw new ZendActionHttpException($this, 500, "ERROR: " . $e->getMessage());
} }