Skip to content
Snippets Groups Projects
Unverified Commit e3a682a8 authored by Chocobozzz's avatar Chocobozzz
Browse files

Handle thumbnail update

parent a0922eb9
No related branches found
No related tags found
No related merge requests found
......@@ -158,8 +158,13 @@ app.use(function (req, res, next) {
})
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 -----------
......
......@@ -195,7 +195,10 @@ async function addVideo (req: express.Request, res: express.Response, videoPhysi
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']
......
......@@ -21,7 +21,7 @@ function keysExcluder (key, value) {
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
......
......@@ -11,7 +11,10 @@ import { ActorModel } from '../../../models/activitypub/actor'
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)
......@@ -82,6 +85,10 @@ async function updateRemoteVideo (actor: ActorModel, activity: ActivityUpdate) {
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) {
......
......@@ -11,12 +11,12 @@ function asyncMiddleware (fun: RequestPromiseHandler | RequestPromiseHandler[])
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))
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment