X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server%2Flib%2Fschedulers%2Fvideo-channel-sync-latest-scheduler.ts;h=efb957fac044e3032f13fc6893ebb0dcc8a6a92c;hb=58e735dd77a4ea8fc9e8da3b54fd338bf9e3558b;hp=491ddaa87149aeafc944d987876d482a70282f81;hpb=a3b472a12ec6e57dbe2f650419f8064864686eab;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/schedulers/video-channel-sync-latest-scheduler.ts b/server/lib/schedulers/video-channel-sync-latest-scheduler.ts index 491ddaa87..efb957fac 100644 --- a/server/lib/schedulers/video-channel-sync-latest-scheduler.ts +++ b/server/lib/schedulers/video-channel-sync-latest-scheduler.ts @@ -2,7 +2,6 @@ import { logger } from '@server/helpers/logger' import { CONFIG } from '@server/initializers/config' import { VideoChannelModel } from '@server/models/video/video-channel' import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync' -import { VideoChannelSyncState } from '@shared/models' import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' import { synchronizeChannel } from '../sync-channel' import { AbstractScheduler } from './abstract-scheduler' @@ -16,38 +15,32 @@ export class VideoChannelSyncLatestScheduler extends AbstractScheduler { } protected async internalExecute () { - logger.debug('Running %s.%s', this.constructor.name, this.internalExecute.name) - if (!CONFIG.IMPORT.VIDEO_CHANNEL_SYNCHRONIZATION.ENABLED) { - logger.info('Discard channels synchronization as the feature is disabled') + logger.debug('Discard channels synchronization as the feature is disabled') return } + logger.info('Checking channels to synchronize') + const channelSyncs = await VideoChannelSyncModel.listSyncs() for (const sync of channelSyncs) { const channel = await VideoChannelModel.loadAndPopulateAccount(sync.videoChannelId) - try { - logger.info( - 'Creating video import jobs for "%s" sync with external channel "%s"', - channel.Actor.preferredUsername, sync.externalChannelUrl - ) - - const onlyAfter = sync.lastSyncAt || sync.createdAt - - await synchronizeChannel({ - channel, - externalChannelUrl: sync.externalChannelUrl, - videosCountLimit: CONFIG.IMPORT.VIDEO_CHANNEL_SYNCHRONIZATION.VIDEOS_LIMIT_PER_SYNCHRONIZATION, - channelSync: sync, - onlyAfter - }) - } catch (err) { - logger.error(`Failed to synchronize channel ${channel.Actor.preferredUsername}`, { err }) - sync.state = VideoChannelSyncState.FAILED - await sync.save() - } + logger.info( + 'Creating video import jobs for "%s" sync with external channel "%s"', + channel.Actor.preferredUsername, sync.externalChannelUrl + ) + + const onlyAfter = sync.lastSyncAt || sync.createdAt + + await synchronizeChannel({ + channel, + externalChannelUrl: sync.externalChannelUrl, + videosCountLimit: CONFIG.IMPORT.VIDEO_CHANNEL_SYNCHRONIZATION.VIDEOS_LIMIT_PER_SYNCHRONIZATION, + channelSync: sync, + onlyAfter + }) } }