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()
|
||||
&& $this->getRequest()->getParam("sharing_token") != Application_Model_Preference::getStationPodcastDownloadKey())
|
||||
&& !RestAuth::verifyAuth(true, true, $this)) {
|
||||
&& !RestAuth::verifyAuth(true, false, $this)) {
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(401);
|
||||
return;
|
||||
|
|
|
@ -183,7 +183,8 @@ class Application_Model_StoredFile
|
|||
// first admin user we find
|
||||
if (!array_key_exists('owner_id', $p_md)) {
|
||||
//$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
|
||||
$owner = $admins[0];
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ class Application_Service_MediaService
|
|||
->filterByDbUtime($oneHourAgo, Criteria::LESS_EQUAL)
|
||||
->find();
|
||||
$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 PENDING_EPISODE_TIMEOUT_SECONDS = 3600;
|
||||
const PENDING_EPISODE_TIMEOUT_SECONDS = 900;
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
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()
|
||||
->filterByDbFileId()
|
||||
->find();
|
||||
|
@ -254,7 +257,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
|
|||
->findOneByDbForeignId(strval($episode->getDbId()));
|
||||
if (!empty($ref)) {
|
||||
$task = CeleryTasksQuery::create()
|
||||
->filterByDbDispatchTime($oneHourAgo, Criteria::LESS_EQUAL)
|
||||
->filterByDbDispatchTime($timeout, Criteria::LESS_EQUAL)
|
||||
->findOneByDbTrackReference($ref->getDbId());
|
||||
if (!empty($task)) {
|
||||
array_push($stuckImports, $episode);
|
||||
|
|
|
@ -1611,7 +1611,9 @@ var AIRTIME = (function(AIRTIME) {
|
|||
if (!$.isEmptyObject(data.file)) {
|
||||
mod.dblClickAdd(data.file, data.file.ftype);
|
||||
} 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