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) {
|
public function updateTrackReference($task, $episodeId, $episode, $status) {
|
||||||
$ref = parent::updateTrackReference($task, $episodeId, $episode, $status);
|
$ref = parent::updateTrackReference($task, $episodeId, $episode, $status);
|
||||||
|
$dbEpisode = PodcastEpisodesQuery::create()->findOneByDbId($episode->episodeid);
|
||||||
|
|
||||||
$dbEpisode = PodcastEpisodesQuery::create()
|
try {
|
||||||
->findOneByDbId($episode->episodeid);
|
// 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
|
// Even if the task itself succeeds, the download could have failed, so check the status
|
||||||
if (!$dbEpisode) {
|
if ($status == CELERY_SUCCESS_STATUS && $episode->status == 1) {
|
||||||
Logging::warn("Celery task $task episode $episode->episodeid unsuccessful: episode placeholder removed");
|
$dbEpisode->setDbFileId($episode->fileid)->save();
|
||||||
return $ref;
|
} else {
|
||||||
}
|
Logging::warn("Celery task $task episode $episode->episodeid unsuccessful with message $episode->error");
|
||||||
|
$dbEpisode->delete();
|
||||||
// Even if the task itself succeeds, the download could have failed, so check the status
|
}
|
||||||
if ($status == CELERY_SUCCESS_STATUS && $episode->status == 1) {
|
} catch (Exception $e) {
|
||||||
$dbEpisode->setDbFileId($episode->fileid)->save();
|
|
||||||
} else {
|
|
||||||
Logging::warn("Celery task $task episode $episode->episodeid unsuccessful with message $episode->error");
|
|
||||||
$dbEpisode->delete();
|
$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;
|
return $ref;
|
||||||
|
|
|
@ -1443,6 +1443,7 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
var selected = this.getSelectedRows(), isValid = true;
|
var selected = this.getSelectedRows(), isValid = true;
|
||||||
if (selected.length == 0) return false;
|
if (selected.length == 0) return false;
|
||||||
$.each(selected, function () {
|
$.each(selected, function () {
|
||||||
|
if (this.ingested < 0) isValid = false;
|
||||||
var isImported = !$.isEmptyObject(this.file);
|
var isImported = !$.isEmptyObject(this.file);
|
||||||
if ((!shouldBeImported && isImported) || (shouldBeImported && !isImported)) {
|
if ((!shouldBeImported && isImported) || (shouldBeImported && !isImported)) {
|
||||||
isValid = false;
|
isValid = false;
|
||||||
|
@ -1483,6 +1484,7 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
click: function () {
|
click: function () {
|
||||||
var data = [], episodes = mod.podcastEpisodeTableWidget.getSelectedRows();
|
var data = [], episodes = mod.podcastEpisodeTableWidget.getSelectedRows();
|
||||||
$.each(episodes, function () {
|
$.each(episodes, function () {
|
||||||
|
if (this.file.ftype === "") { this.file.ftype = "audioclip"; }
|
||||||
data.push({id: this.file.id, type: this.file.ftype});
|
data.push({id: this.file.id, type: this.file.ftype});
|
||||||
});
|
});
|
||||||
mod.fnDeleteItems(data);
|
mod.fnDeleteItems(data);
|
||||||
|
|
|
@ -210,7 +210,10 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
btn.element = buttonElement; //Save this guy in case you need it later.
|
btn.element = buttonElement; //Save this guy in case you need it later.
|
||||||
//Bind event handlers to each button
|
//Bind event handlers to each button
|
||||||
$.each(btn.eventHandlers, function(eventName, eventCallback) {
|
$.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)
|
@celery.task(name='podcast-download', acks_late=True)
|
||||||
def podcast_download(id, url, callback_url, api_key):
|
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 id: episode unique ID
|
||||||
:param url: download url for the episode
|
:param url: download url for the episode
|
||||||
|
|
Loading…
Reference in New Issue