X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fvideo-state.ts;h=97ff540edce61f9db211a74f914dc3d938b1cdda;hb=8d07888728bc5aabc7d0cd6211bc49fc45fd0353;hp=2260e90f531449a416a528d898d4e32a84e3ed58;hpb=4e29f4fe23b413cc8c55ac0d8373f36bcd60b47a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/video-state.ts b/server/lib/video-state.ts index 2260e90f5..97ff540ed 100644 --- a/server/lib/video-state.ts +++ b/server/lib/video-state.ts @@ -4,7 +4,7 @@ import { CONFIG } from '@server/initializers/config' import { sequelizeTypescript } from '@server/initializers/database' import { VideoModel } from '@server/models/video/video' import { VideoJobInfoModel } from '@server/models/video/video-job-info' -import { MVideoFullLight, MVideoUUID } from '@server/types/models' +import { MVideo, MVideoFullLight, MVideoUUID } from '@server/types/models' import { VideoState } from '@shared/models' import { federateVideoIfNeeded } from './activitypub/videos' import { Notifier } from './notifier' @@ -79,10 +79,16 @@ async function moveToExternalStorageState (video: MVideoFullLight, isNewVideo: b } } -function moveToFailedState (video: MVideoFullLight) { - return sequelizeTypescript.transaction(async t => { - await video.setNewState(VideoState.TRANSCODING_FAILED, false, t) - }) +function moveToFailedTranscodingState (video: MVideo) { + if (video.state === VideoState.TRANSCODING_FAILED) return + + return video.setNewState(VideoState.TRANSCODING_FAILED, false, undefined) +} + +function moveToFailedMoveToObjectStorageState (video: MVideo) { + if (video.state === VideoState.TO_MOVE_TO_EXTERNAL_STORAGE_FAILED) return + + return video.setNewState(VideoState.TO_MOVE_TO_EXTERNAL_STORAGE_FAILED, false, undefined) } // --------------------------------------------------------------------------- @@ -90,7 +96,8 @@ function moveToFailedState (video: MVideoFullLight) { export { buildNextVideoState, moveToExternalStorageState, - moveToFailedState, + moveToFailedTranscodingState, + moveToFailedMoveToObjectStorageState, moveToNextState } @@ -106,7 +113,9 @@ async function moveToPublishedState (video: MVideoFullLight, isNewVideo: boolean // Live videos are always federated, so it's not a new video await federateVideoIfNeeded(video, isNewVideo, transaction) - if (isNewVideo) Notifier.Instance.notifyOnNewVideoIfNeeded(video) + if (!isNewVideo) return + + Notifier.Instance.notifyOnNewVideoIfNeeded(video) if (previousState === VideoState.TO_TRANSCODE) { Notifier.Instance.notifyOnVideoPublishedAfterTranscoding(video)