Transcoding failed, this video may not work properly.
</div>
+<div i18n class="alert alert-warning" *ngIf="isVideoMoveToObjectStorageFailed()">
+ Move to external storage failed, this video may not work properly.
+</div>
+
<div i18n class="alert alert-warning" *ngIf="isVideoToImport()">
The video is being imported, it will be available when the import is finished.
</div>
return this.video && this.video.state.id === VideoState.TRANSCODING_FAILED
}
+ isVideoMoveToObjectStorageFailed () {
+ return this.video && this.video.state.id === VideoState.TO_MOVE_TO_EXTERNAL_STORAGE_FAILED
+ }
+
isVideoToImport () {
return this.video && this.video.state.id === VideoState.TO_IMPORT
}
return $localize`Transcoding failed`
}
+ if (video.state.id === VideoState.TO_MOVE_TO_EXTERNAL_STORAGE_FAILED) {
+ return $localize`Move to external storage failed`
+ }
+
if (video.state.id === VideoState.TO_TRANSCODE && video.waitTranscoding === true) {
return $localize`Waiting transcoding`
}
import { program } from 'commander'
import { VideoModel } from '@server/models/video/video'
import { initDatabaseModels } from '@server/initializers/database'
-import { VideoStorage } from '@shared/models'
+import { VideoState, VideoStorage } from '@shared/models'
import { moveToExternalStorageState } from '@server/lib/video-state'
import { JobQueue } from '@server/lib/job-queue'
import { CONFIG } from '@server/initializers/config'
process.exit(-1)
}
+ if (video.state === VideoState.TO_MOVE_TO_EXTERNAL_STORAGE) {
+ console.error('This video is already being moved to external storage')
+ process.exit(-1)
+ }
+
ids.push(video.id)
} else {
ids = await VideoModel.listLocalIds()
[VideoState.WAITING_FOR_LIVE]: 'Waiting for livestream',
[VideoState.LIVE_ENDED]: 'Livestream ended',
[VideoState.TO_MOVE_TO_EXTERNAL_STORAGE]: 'To move to an external storage',
- [VideoState.TRANSCODING_FAILED]: 'Transcoding failed'
+ [VideoState.TRANSCODING_FAILED]: 'Transcoding failed',
+ [VideoState.TO_MOVE_TO_EXTERNAL_STORAGE_FAILED]: 'External storage move failed'
}
const VIDEO_IMPORT_STATES: { [ id in VideoImportState ]: string } = {
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'
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)
+ }
+ } catch (err) {
+ logger.error('Cannot move video %s to object storage.', video.url, { err })
- 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)
+ await moveToFailedMoveToObjectStorageState(video)
+ await VideoJobInfoModel.abortAllTasks(video.uuid, 'pendingMove')
}
return payload.videoUUID
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'
}
}
-function moveToFailedTranscodingState (video: MVideoFullLight) {
+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)
+}
+
// ---------------------------------------------------------------------------
export {
buildNextVideoState,
moveToExternalStorageState,
moveToFailedTranscodingState,
+ moveToFailedMoveToObjectStorageState,
moveToNextState
}
return pendingMove
}
+
+ static async abortAllTasks (videoUUID: string, column: VideoJobInfoColumnType): Promise<void> {
+ const options = { type: QueryTypes.UPDATE as QueryTypes.UPDATE, bind: { videoUUID } }
+
+ await VideoJobInfoModel.sequelize.query(`
+ UPDATE
+ "videoJobInfo"
+ SET
+ "${column}" = 0,
+ "updatedAt" = NOW()
+ FROM "video"
+ WHERE
+ "video"."id" = "videoJobInfo"."videoId" AND "video"."uuid" = $videoUUID
+ `, options)
+ }
}
WAITING_FOR_LIVE = 4,
LIVE_ENDED = 5,
TO_MOVE_TO_EXTERNAL_STORAGE = 6,
- TRANSCODING_FAILED = 7
+ TRANSCODING_FAILED = 7,
+ TO_MOVE_TO_EXTERNAL_STORAGE_FAILED = 8
}