Fix error when deleting SoundCloud tracks

This commit is contained in:
Duncan Sommerville 2015-06-16 16:21:31 -04:00
parent 0cd9b1d0e5
commit e033360a4e
2 changed files with 13 additions and 14 deletions

View file

@ -81,6 +81,10 @@ class CeleryService {
// If the message isn't ready yet (Celery hasn't finished the task),
// only throw an exception if the message has timed out.
if ($message == FALSE && self::_checkMessageTimeout($task)) {
// If the task times out, mark it as failed. We don't want to remove the
// track reference here in case it was a deletion that failed, for example.
$task->setDbStatus(CELERY_FAILED_STATUS);
$task->save();
throw new CeleryTimeoutException("Celery task " . $task->getDbName()
. " with ID " . $task->getDbId() . " timed out");
}
@ -117,11 +121,6 @@ class CeleryService {
$message = self::_getTaskMessage($task);
self::_processTaskMessage($task, $message);
} catch (CeleryTimeoutException $e) {
// If the task times out, mark it as failed. We don't want to remove the
// track reference here in case it was a deletion that failed, for example.
// TODO: Move this somewhere more appropriate
$task->setDbStatus(CELERY_FAILED_STATUS);
$task->save();
Logging::info($e->getMessage());
} catch (Exception $e) {
// Because $message->result can be either an object or a string, sometimes

View file

@ -114,6 +114,15 @@ abstract class ThirdPartyCeleryService extends ThirdPartyService {
$ref->save();
}
/**
* Field accessor for $_CELERY_DELETE_TASK_NAME
*
* @return string the Celery task name for deleting tracks from this service
*/
public function getCeleryDeleteTaskName() {
return static::$_CELERY_DELETE_TASK_NAME;
}
/**
* Build a parameter array for the file being uploaded to a third party service
*
@ -123,13 +132,4 @@ abstract class ThirdPartyCeleryService extends ThirdPartyService {
*/
abstract protected function _getUploadData($file);
/**
* Field accessor for $_CELERY_DELETE_TASK_NAME
*
* @return string the Celery task name for deleting tracks from this service
*/
public function getCeleryDeleteTaskName() {
return self::$_CELERY_DELETE_TASK_NAME;
}
}