Add some additional error handling and prevent disabled buttons from being triggered
This commit is contained in:
parent
8a5c25291e
commit
071de55329
|
@ -161,22 +161,26 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
|
|||
*/
|
||||
public function updateTrackReference($task, $episodeId, $episode, $status) {
|
||||
$ref = parent::updateTrackReference($task, $episodeId, $episode, $status);
|
||||
$dbEpisode = PodcastEpisodesQuery::create()->findOneByDbId($episode->episodeid);
|
||||
|
||||
$dbEpisode = PodcastEpisodesQuery::create()
|
||||
->findOneByDbId($episode->episodeid);
|
||||
try {
|
||||
// If the placeholder for the episode is somehow removed, return with a warning
|
||||
if (!$dbEpisode) {
|
||||
Logging::warn("Celery task $task episode $episode->episodeid unsuccessful: episode placeholder removed");
|
||||
return $ref;
|
||||
}
|
||||
|
||||
// If the placeholder for the episode is somehow removed, return with a warning
|
||||
if (!$dbEpisode) {
|
||||
Logging::warn("Celery task $task episode $episode->episodeid unsuccessful: episode placeholder removed");
|
||||
return $ref;
|
||||
}
|
||||
|
||||
// Even if the task itself succeeds, the download could have failed, so check the status
|
||||
if ($status == CELERY_SUCCESS_STATUS && $episode->status == 1) {
|
||||
$dbEpisode->setDbFileId($episode->fileid)->save();
|
||||
} else {
|
||||
Logging::warn("Celery task $task episode $episode->episodeid unsuccessful with message $episode->error");
|
||||
// Even if the task itself succeeds, the download could have failed, so check the status
|
||||
if ($status == CELERY_SUCCESS_STATUS && $episode->status == 1) {
|
||||
$dbEpisode->setDbFileId($episode->fileid)->save();
|
||||
} else {
|
||||
Logging::warn("Celery task $task episode $episode->episodeid unsuccessful with message $episode->error");
|
||||
$dbEpisode->delete();
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$dbEpisode->delete();
|
||||
Logging::warn("Catastrophic failure updating from task $task, recovering by deleting episode row.\n
|
||||
This can occur if the episode's corresponding CcFile is deleted before being processed.");
|
||||
}
|
||||
|
||||
return $ref;
|
||||
|
|
|
@ -1443,6 +1443,7 @@ var AIRTIME = (function(AIRTIME) {
|
|||
var selected = this.getSelectedRows(), isValid = true;
|
||||
if (selected.length == 0) return false;
|
||||
$.each(selected, function () {
|
||||
if (this.ingested < 0) isValid = false;
|
||||
var isImported = !$.isEmptyObject(this.file);
|
||||
if ((!shouldBeImported && isImported) || (shouldBeImported && !isImported)) {
|
||||
isValid = false;
|
||||
|
@ -1483,6 +1484,7 @@ var AIRTIME = (function(AIRTIME) {
|
|||
click: function () {
|
||||
var data = [], episodes = mod.podcastEpisodeTableWidget.getSelectedRows();
|
||||
$.each(episodes, function () {
|
||||
if (this.file.ftype === "") { this.file.ftype = "audioclip"; }
|
||||
data.push({id: this.file.id, type: this.file.ftype});
|
||||
});
|
||||
mod.fnDeleteItems(data);
|
||||
|
|
|
@ -210,7 +210,10 @@ var AIRTIME = (function(AIRTIME) {
|
|||
btn.element = buttonElement; //Save this guy in case you need it later.
|
||||
//Bind event handlers to each button
|
||||
$.each(btn.eventHandlers, function(eventName, eventCallback) {
|
||||
$(buttonElement).on(eventName, eventCallback);
|
||||
$(buttonElement).on(eventName, function () {
|
||||
if ($(buttonElement).find("button").is(':disabled')) { return; }
|
||||
eventCallback();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ def soundcloud_delete(token, track_id):
|
|||
@celery.task(name='podcast-download', acks_late=True)
|
||||
def podcast_download(id, url, callback_url, api_key):
|
||||
"""
|
||||
Download a batch of podcast episodes
|
||||
Download a podcast episode
|
||||
|
||||
:param id: episode unique ID
|
||||
:param url: download url for the episode
|
||||
|
|
Loading…
Reference in New Issue