})
app.use(function (err, req, res, next) {
- logger.error('Error in controller.', { error: err.stack || err.message || err })
- res.sendStatus(err.status || 500)
+ let error = 'Unknown error.'
+ if (err) {
+ error = err.stack || err.message || err
+ }
+
+ logger.error('Error in controller.', { error })
+ return res.status(err.status || 500).end()
})
// ----------- Run -----------
const videoFile = new VideoFileModel(videoFileData)
const videoDir = CONFIG.STORAGE.VIDEOS_DIR
const destination = join(videoDir, video.getVideoFilename(videoFile))
+
await renamePromise(videoPhysicalFile.path, destination)
+ // This is important in case if there is another attempt in the retry process
+ videoPhysicalFile.filename = video.getVideoFilename(videoFile)
// Process thumbnail or create it from the video
const thumbnailField = req.files['thumbnailfile']
return excludedKeys[key] === true ? undefined : value
}
-const loggerFormat = winston.format.printf((info) => {
+const loggerFormat = winston.format.printf(info => {
let additionalInfos = JSON.stringify(info, keysExcluder, 2)
if (additionalInfos === '{}') additionalInfos = ''
else additionalInfos = ' ' + additionalInfos
import { TagModel } from '../../../models/video/tag'
import { VideoFileModel } from '../../../models/video/video-file'
import { fetchAvatarIfExists, getOrCreateActorAndServerAndModel, updateActorAvatarInstance, updateActorInstance } from '../actor'
-import { getOrCreateAccountAndVideoAndChannel, videoActivityObjectToDBAttributes, videoFileActivityUrlToDBAttributes } from '../videos'
+import {
+ generateThumbnailFromUrl, getOrCreateAccountAndVideoAndChannel, videoActivityObjectToDBAttributes,
+ videoFileActivityUrlToDBAttributes
+} from '../videos'
async function processUpdateActivity (activity: ActivityUpdate) {
const actor = await getOrCreateActorAndServerAndModel(activity.actor)
await videoInstance.save(sequelizeOptions)
+ // Don't block on request
+ generateThumbnailFromUrl(videoInstance, videoAttributesToUpdate.icon)
+ .catch(err => logger.warn('Cannot generate thumbnail of %s.', videoAttributesToUpdate.id, err))
+
// Remove old video files
const videoFileDestroyTasks: Bluebird<void>[] = []
for (const videoFile of videoInstance.VideoFiles) {
if (Array.isArray(fun) === true) {
return eachSeries(fun as RequestHandler[], (f, cb) => {
Promise.resolve(f(req, res, cb))
- .catch(next)
+ .catch(err => next(err))
}, next)
}
return Promise.resolve((fun as RequestHandler)(req, res, next))
- .catch(next)
+ .catch(err => next(err))
}
}