Fix video_share_url duplicate key in transcoding job

This commit is contained in:
Chocobozzz 2018-03-19 15:02:36 +01:00
parent 9d145133d8
commit a797728009
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
6 changed files with 63 additions and 44 deletions

View File

@ -26,6 +26,10 @@
* Added `privacy.id` field
* Added `privacy.label` field
### Bug fixes
* Fix video_share_url duplicate key on failed transcoding job
## v1.0.0-alpha.8
@ -63,7 +67,6 @@
* Add "Local" in menu that lists only local videos
## v1.0.0-alpha.4
### Features

View File

@ -56,7 +56,7 @@ async function inboxController (req: express.Request, res: express.Response, nex
specificActor = res.locals.videoChannel
}
logger.info('Receiving inbox requests for %d activities by %s.', activities.length, res.locals.signature.actor)
logger.info('Receiving inbox requests for %d activities by %s.', activities.length, res.locals.signature.actor.url)
await processActivities(activities, res.locals.signature.actor, specificActor)

View File

@ -1,7 +1,7 @@
import * as ffmpeg from 'fluent-ffmpeg'
import { join } from 'path'
import { VideoResolution } from '../../shared/models/videos'
import { CONFIG, MAX_VIDEO_TRANSCODING_FPS } from '../initializers'
import { CONFIG, VIDEO_TRANSCODING_FPS } from '../initializers'
import { unlinkPromise } from './core-utils'
import { processImage } from './image-utils'
import { logger } from './logger'
@ -92,7 +92,9 @@ function transcode (options: TranscodeOptions) {
.outputOption('-movflags faststart')
// .outputOption('-crf 18')
if (fps > MAX_VIDEO_TRANSCODING_FPS) command = command.withFPS(MAX_VIDEO_TRANSCODING_FPS)
// Our player has some FPS limits
if (fps > VIDEO_TRANSCODING_FPS.MAX) command = command.withFPS(VIDEO_TRANSCODING_FPS.MAX)
else if (fps < VIDEO_TRANSCODING_FPS.MIN) command = command.withFPS(VIDEO_TRANSCODING_FPS.MIN)
if (options.resolution !== undefined) {
// '?x720' or '720x?' for example

View File

@ -234,7 +234,10 @@ const CONSTRAINTS_FIELDS = {
}
let VIDEO_VIEW_LIFETIME = 60000 * 60 // 1 hour
const MAX_VIDEO_TRANSCODING_FPS = 30
const VIDEO_TRANSCODING_FPS = {
MIN: 10,
MAX: 30
}
const VIDEO_RATE_TYPES: { [ id: string ]: VideoRateType } = {
LIKE: 'like',
@ -445,7 +448,7 @@ export {
VIDEO_LICENCES,
VIDEO_RATE_TYPES,
VIDEO_MIMETYPE_EXT,
MAX_VIDEO_TRANSCODING_FPS,
VIDEO_TRANSCODING_FPS,
USER_PASSWORD_RESET_LIFETIME,
IMAGE_MIMETYPE_EXT,
SCHEDULER_INTERVAL,

View File

@ -12,27 +12,42 @@ async function shareVideoByServerAndChannel (video: VideoModel, t: Transaction)
const serverActor = await getServerActor()
const serverShareUrl = getAnnounceActivityPubUrl(video.url, serverActor)
const serverSharePromise = VideoShareModel.create({
const serverSharePromise = VideoShareModel.findOrCreate({
defaults: {
actorId: serverActor.id,
videoId: video.id,
url: serverShareUrl
}, { transaction: t })
},
where: {
url: serverShareUrl
},
transaction: t
}).then(([ serverShare, created ]) => {
if (created) return sendVideoAnnounceToFollowers(serverActor, serverShare, video, t)
return undefined
})
const videoChannelShareUrl = getAnnounceActivityPubUrl(video.url, video.VideoChannel.Actor)
const videoChannelSharePromise = VideoShareModel.create({
const videoChannelSharePromise = VideoShareModel.findOrCreate({
defaults: {
actorId: video.VideoChannel.actorId,
videoId: video.id,
url: videoChannelShareUrl
}, { transaction: t })
},
where: {
url: videoChannelShareUrl
},
transaction: t
}).then(([ videoChannelShare, created ]) => {
if (created) return sendVideoAnnounceToFollowers(serverActor, videoChannelShare, video, t)
const [ serverShare, videoChannelShare ] = await Promise.all([
serverSharePromise,
videoChannelSharePromise
])
return undefined
})
return Promise.all([
sendVideoAnnounceToFollowers(serverActor, videoChannelShare, video, t),
sendVideoAnnounceToFollowers(serverActor, serverShare, video, t)
serverSharePromise,
videoChannelSharePromise
])
}

View File

@ -63,8 +63,10 @@ async function onVideoFileOptimizerSuccess (video: VideoModel) {
if (video.privacy !== VideoPrivacy.PRIVATE) {
// Now we'll add the video's meta data to our followers
await sendCreateVideo(video, undefined)
await shareVideoByServerAndChannel(video, undefined)
await sequelizeTypescript.transaction(async t => {
await sendCreateVideo(video, t)
await shareVideoByServerAndChannel(video, t)
})
}
const { videoFileResolution } = await videoDatabase.getOriginalFileResolution()
@ -77,8 +79,6 @@ async function onVideoFileOptimizerSuccess (video: VideoModel) {
)
if (resolutionsEnabled.length !== 0) {
try {
await sequelizeTypescript.transaction(async t => {
const tasks: Promise<any>[] = []
for (const resolution of resolutionsEnabled) {
@ -92,12 +92,8 @@ async function onVideoFileOptimizerSuccess (video: VideoModel) {
}
await Promise.all(tasks)
})
logger.info('Transcoding jobs created for uuid %s.', videoDatabase.uuid, { resolutionsEnabled })
} catch (err) {
logger.warn('Cannot transcode the video.', err)
}
} else {
logger.info('No transcoding jobs created for video %s (no resolutions enabled).')
return undefined