SAAS-1244 - improve pending podcast episode sweeping; small bugfixes
This commit is contained in:
parent
21846be7ed
commit
17a03e088f
|
@ -9,7 +9,7 @@ class FeedsController extends Zend_Controller_Action
|
||||||
|
|
||||||
if ((Application_Model_Preference::getStationPodcastPrivacy()
|
if ((Application_Model_Preference::getStationPodcastPrivacy()
|
||||||
&& $this->getRequest()->getParam("sharing_token") != Application_Model_Preference::getStationPodcastDownloadKey())
|
&& $this->getRequest()->getParam("sharing_token") != Application_Model_Preference::getStationPodcastDownloadKey())
|
||||||
&& !RestAuth::verifyAuth(true, true, $this)) {
|
&& !RestAuth::verifyAuth(true, false, $this)) {
|
||||||
$this->getResponse()
|
$this->getResponse()
|
||||||
->setHttpResponseCode(401);
|
->setHttpResponseCode(401);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -183,7 +183,8 @@ class Application_Model_StoredFile
|
||||||
// first admin user we find
|
// first admin user we find
|
||||||
if (!array_key_exists('owner_id', $p_md)) {
|
if (!array_key_exists('owner_id', $p_md)) {
|
||||||
//$admins = Application_Model_User::getUsers(array('A'));
|
//$admins = Application_Model_User::getUsers(array('A'));
|
||||||
$admins = Application_Model_User::getUsersOfType('A');
|
$admins = array_merge(Application_Model_User::getUsersOfType('A')->getData(),
|
||||||
|
Application_Model_User::getUsersOfType('S')->getData());
|
||||||
if (count($admins) > 0) { // found admin => pick first one
|
if (count($admins) > 0) { // found admin => pick first one
|
||||||
$owner = $admins[0];
|
$owner = $admins[0];
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ class Application_Service_MediaService
|
||||||
->filterByDbUtime($oneHourAgo, Criteria::LESS_EQUAL)
|
->filterByDbUtime($oneHourAgo, Criteria::LESS_EQUAL)
|
||||||
->find();
|
->find();
|
||||||
$pendingEpisodes = Application_Service_PodcastEpisodeService::getStuckPendingImports();
|
$pendingEpisodes = Application_Service_PodcastEpisodeService::getStuckPendingImports();
|
||||||
return !empty(self::$_pendingFiles) && !empty($pendingEpisodes);
|
return !self::$_pendingFiles->isEmpty() || !empty($pendingEpisodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
|
||||||
|
|
||||||
const DOWNLOAD = 'download';
|
const DOWNLOAD = 'download';
|
||||||
|
|
||||||
const PENDING_EPISODE_TIMEOUT_SECONDS = 3600;
|
const PENDING_EPISODE_TIMEOUT_SECONDS = 900;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string service name to store in ThirdPartyTrackReferences database
|
* @var string service name to store in ThirdPartyTrackReferences database
|
||||||
|
@ -239,12 +239,15 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find any episode placeholders that have been stuck pending (empty file ID) for over an hour
|
* Find any episode placeholders that have been stuck pending (empty file ID) for over
|
||||||
|
* PENDING_EPISODE_TIMEOUT_SECONDS
|
||||||
|
*
|
||||||
|
* @see Application_Service_PodcastEpisodeService::PENDING_EPISODE_TIMEOUT_SECONDS
|
||||||
*
|
*
|
||||||
* @return array the episode imports stuck in pending
|
* @return array the episode imports stuck in pending
|
||||||
*/
|
*/
|
||||||
public static function getStuckPendingImports() {
|
public static function getStuckPendingImports() {
|
||||||
$oneHourAgo = gmdate(DEFAULT_TIMESTAMP_FORMAT, (microtime(true) - self::PENDING_EPISODE_TIMEOUT_SECONDS));
|
$timeout = gmdate(DEFAULT_TIMESTAMP_FORMAT, (microtime(true) - self::PENDING_EPISODE_TIMEOUT_SECONDS));
|
||||||
$episodes = PodcastEpisodesQuery::create()
|
$episodes = PodcastEpisodesQuery::create()
|
||||||
->filterByDbFileId()
|
->filterByDbFileId()
|
||||||
->find();
|
->find();
|
||||||
|
@ -254,7 +257,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
|
||||||
->findOneByDbForeignId(strval($episode->getDbId()));
|
->findOneByDbForeignId(strval($episode->getDbId()));
|
||||||
if (!empty($ref)) {
|
if (!empty($ref)) {
|
||||||
$task = CeleryTasksQuery::create()
|
$task = CeleryTasksQuery::create()
|
||||||
->filterByDbDispatchTime($oneHourAgo, Criteria::LESS_EQUAL)
|
->filterByDbDispatchTime($timeout, Criteria::LESS_EQUAL)
|
||||||
->findOneByDbTrackReference($ref->getDbId());
|
->findOneByDbTrackReference($ref->getDbId());
|
||||||
if (!empty($task)) {
|
if (!empty($task)) {
|
||||||
array_push($stuckImports, $episode);
|
array_push($stuckImports, $episode);
|
||||||
|
|
|
@ -1611,7 +1611,9 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
if (!$.isEmptyObject(data.file)) {
|
if (!$.isEmptyObject(data.file)) {
|
||||||
mod.dblClickAdd(data.file, data.file.ftype);
|
mod.dblClickAdd(data.file, data.file.ftype);
|
||||||
} else {
|
} else {
|
||||||
AIRTIME.podcast.importSelectedEpisodes([data], mod.podcastEpisodeTableWidget);
|
if (data.ingested >= 0) { // Only import if the file isn't pending
|
||||||
|
AIRTIME.podcast.importSelectedEpisodes([data], mod.podcastEpisodeTableWidget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue