1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Don't stuck state when move transcoding job failed

This commit is contained in:
Chocobozzz 2021-12-23 11:09:31 +01:00
parent 482b26231b
commit dbd9fb44dd
No known key found for this signature in database
GPG key ID: 583A612D890159BE
9 changed files with 64 additions and 16 deletions

View file

@ -7,7 +7,7 @@ import { CONFIG } from '@server/initializers/config'
import { P2P_MEDIA_LOADER_PEER_VERSION } from '@server/initializers/constants'
import { storeHLSFile, storeWebTorrentFile } from '@server/lib/object-storage'
import { getHLSDirectory, getHlsResolutionPlaylistFilename } from '@server/lib/paths'
import { moveToNextState } from '@server/lib/video-state'
import { moveToFailedMoveToObjectStorageState, moveToNextState } from '@server/lib/video-state'
import { VideoModel } from '@server/models/video/video'
import { VideoJobInfoModel } from '@server/models/video/video-job-info'
import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models'
@ -24,18 +24,25 @@ export async function processMoveToObjectStorage (job: Job) {
return undefined
}
if (video.VideoFiles) {
await moveWebTorrentFiles(video)
}
try {
if (video.VideoFiles) {
await moveWebTorrentFiles(video)
}
if (video.VideoStreamingPlaylists) {
await moveHLSFiles(video)
}
if (video.VideoStreamingPlaylists) {
await moveHLSFiles(video)
}
const pendingMove = await VideoJobInfoModel.decrease(video.uuid, 'pendingMove')
if (pendingMove === 0) {
logger.info('Running cleanup after moving files to object storage (video %s in job %d)', video.uuid, job.id)
await doAfterLastJob(video, payload.isNewVideo)
const pendingMove = await VideoJobInfoModel.decrease(video.uuid, 'pendingMove')
if (pendingMove === 0) {
logger.info('Running cleanup after moving files to object storage (video %s in job %d)', video.uuid, job.id)
await doAfterLastJob(video, payload.isNewVideo)
}
} catch (err) {
logger.error('Cannot move video %s to object storage.', video.url, { err })
await moveToFailedMoveToObjectStorageState(video)
await VideoJobInfoModel.abortAllTasks(video.uuid, 'pendingMove')
}
return payload.videoUUID