mirror of https://github.com/Chocobozzz/PeerTube
Handle sync failure in synchronizeChannel fn
parent
3097acc7c2
commit
97922ecf64
|
@ -5,7 +5,7 @@ import { synchronizeChannel } from '@server/lib/sync-channel'
|
||||||
import { VideoChannelModel } from '@server/models/video/video-channel'
|
import { VideoChannelModel } from '@server/models/video/video-channel'
|
||||||
import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync'
|
import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync'
|
||||||
import { MChannelSync } from '@server/types/models'
|
import { MChannelSync } from '@server/types/models'
|
||||||
import { VideoChannelImportPayload, VideoChannelSyncState } from '@shared/models'
|
import { VideoChannelImportPayload } from '@shared/models'
|
||||||
|
|
||||||
export async function processVideoChannelImport (job: Job) {
|
export async function processVideoChannelImport (job: Job) {
|
||||||
const payload = job.data as VideoChannelImportPayload
|
const payload = job.data as VideoChannelImportPayload
|
||||||
|
@ -32,7 +32,6 @@ export async function processVideoChannelImport (job: Job) {
|
||||||
|
|
||||||
const videoChannel = await VideoChannelModel.loadAndPopulateAccount(payload.videoChannelId)
|
const videoChannel = await VideoChannelModel.loadAndPopulateAccount(payload.videoChannelId)
|
||||||
|
|
||||||
try {
|
|
||||||
logger.info(`Starting importing videos from external channel "${payload.externalChannelUrl}" to "${videoChannel.name}" `)
|
logger.info(`Starting importing videos from external channel "${payload.externalChannelUrl}" to "${videoChannel.name}" `)
|
||||||
|
|
||||||
await synchronizeChannel({
|
await synchronizeChannel({
|
||||||
|
@ -40,9 +39,4 @@ export async function processVideoChannelImport (job: Job) {
|
||||||
externalChannelUrl: payload.externalChannelUrl,
|
externalChannelUrl: payload.externalChannelUrl,
|
||||||
channelSync
|
channelSync
|
||||||
})
|
})
|
||||||
} catch (err) {
|
|
||||||
logger.error(`Failed to import channel ${videoChannel.name}`, { err })
|
|
||||||
channelSync.state = VideoChannelSyncState.FAILED
|
|
||||||
await channelSync.save()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ import { logger } from '@server/helpers/logger'
|
||||||
import { CONFIG } from '@server/initializers/config'
|
import { CONFIG } from '@server/initializers/config'
|
||||||
import { VideoChannelModel } from '@server/models/video/video-channel'
|
import { VideoChannelModel } from '@server/models/video/video-channel'
|
||||||
import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync'
|
import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync'
|
||||||
import { VideoChannelSyncState } from '@shared/models'
|
|
||||||
import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants'
|
import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants'
|
||||||
import { synchronizeChannel } from '../sync-channel'
|
import { synchronizeChannel } from '../sync-channel'
|
||||||
import { AbstractScheduler } from './abstract-scheduler'
|
import { AbstractScheduler } from './abstract-scheduler'
|
||||||
|
@ -28,7 +27,6 @@ export class VideoChannelSyncLatestScheduler extends AbstractScheduler {
|
||||||
for (const sync of channelSyncs) {
|
for (const sync of channelSyncs) {
|
||||||
const channel = await VideoChannelModel.loadAndPopulateAccount(sync.videoChannelId)
|
const channel = await VideoChannelModel.loadAndPopulateAccount(sync.videoChannelId)
|
||||||
|
|
||||||
try {
|
|
||||||
logger.info(
|
logger.info(
|
||||||
'Creating video import jobs for "%s" sync with external channel "%s"',
|
'Creating video import jobs for "%s" sync with external channel "%s"',
|
||||||
channel.Actor.preferredUsername, sync.externalChannelUrl
|
channel.Actor.preferredUsername, sync.externalChannelUrl
|
||||||
|
@ -43,11 +41,6 @@ export class VideoChannelSyncLatestScheduler extends AbstractScheduler {
|
||||||
channelSync: sync,
|
channelSync: sync,
|
||||||
onlyAfter
|
onlyAfter
|
||||||
})
|
})
|
||||||
} catch (err) {
|
|
||||||
logger.error(`Failed to synchronize channel ${channel.Actor.preferredUsername}`, { err })
|
|
||||||
sync.state = VideoChannelSyncState.FAILED
|
|
||||||
await sync.save()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ export async function synchronizeChannel (options: {
|
||||||
await channelSync.save()
|
await channelSync.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
const user = await UserModel.loadByChannelActorId(channel.actorId)
|
const user = await UserModel.loadByChannelActorId(channel.actorId)
|
||||||
const youtubeDL = new YoutubeDLWrapper(
|
const youtubeDL = new YoutubeDLWrapper(
|
||||||
externalChannelUrl,
|
externalChannelUrl,
|
||||||
|
@ -74,6 +75,11 @@ export async function synchronizeChannel (options: {
|
||||||
}
|
}
|
||||||
|
|
||||||
await JobQueue.Instance.createJobWithChildren(parent, children)
|
await JobQueue.Instance.createJobWithChildren(parent, children)
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(`Failed to import channel ${channel.name}`, { err })
|
||||||
|
channelSync.state = VideoChannelSyncState.FAILED
|
||||||
|
await channelSync.save()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue