aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/videos/index.ts3
-rw-r--r--server/helpers/logger.ts2
-rw-r--r--server/lib/activitypub/process/process-update.ts9
-rw-r--r--server/middlewares/async.ts4
4 files changed, 14 insertions, 4 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 1a4de081f..10b6c000f 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -195,7 +195,10 @@ async function addVideo (req: express.Request, res: express.Response, videoPhysi
195 const videoFile = new VideoFileModel(videoFileData) 195 const videoFile = new VideoFileModel(videoFileData)
196 const videoDir = CONFIG.STORAGE.VIDEOS_DIR 196 const videoDir = CONFIG.STORAGE.VIDEOS_DIR
197 const destination = join(videoDir, video.getVideoFilename(videoFile)) 197 const destination = join(videoDir, video.getVideoFilename(videoFile))
198
198 await renamePromise(videoPhysicalFile.path, destination) 199 await renamePromise(videoPhysicalFile.path, destination)
200 // This is important in case if there is another attempt in the retry process
201 videoPhysicalFile.filename = video.getVideoFilename(videoFile)
199 202
200 // Process thumbnail or create it from the video 203 // Process thumbnail or create it from the video
201 const thumbnailField = req.files['thumbnailfile'] 204 const thumbnailField = req.files['thumbnailfile']
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts
index 201ea2235..bcd4885af 100644
--- a/server/helpers/logger.ts
+++ b/server/helpers/logger.ts
@@ -21,7 +21,7 @@ function keysExcluder (key, value) {
21 return excludedKeys[key] === true ? undefined : value 21 return excludedKeys[key] === true ? undefined : value
22} 22}
23 23
24const loggerFormat = winston.format.printf((info) => { 24const loggerFormat = winston.format.printf(info => {
25 let additionalInfos = JSON.stringify(info, keysExcluder, 2) 25 let additionalInfos = JSON.stringify(info, keysExcluder, 2)
26 if (additionalInfos === '{}') additionalInfos = '' 26 if (additionalInfos === '{}') additionalInfos = ''
27 else additionalInfos = ' ' + additionalInfos 27 else additionalInfos = ' ' + additionalInfos
diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts
index c0038be64..c7ad412bc 100644
--- a/server/lib/activitypub/process/process-update.ts
+++ b/server/lib/activitypub/process/process-update.ts
@@ -11,7 +11,10 @@ import { ActorModel } from '../../../models/activitypub/actor'
11import { TagModel } from '../../../models/video/tag' 11import { TagModel } from '../../../models/video/tag'
12import { VideoFileModel } from '../../../models/video/video-file' 12import { VideoFileModel } from '../../../models/video/video-file'
13import { fetchAvatarIfExists, getOrCreateActorAndServerAndModel, updateActorAvatarInstance, updateActorInstance } from '../actor' 13import { fetchAvatarIfExists, getOrCreateActorAndServerAndModel, updateActorAvatarInstance, updateActorInstance } from '../actor'
14import { getOrCreateAccountAndVideoAndChannel, videoActivityObjectToDBAttributes, videoFileActivityUrlToDBAttributes } from '../videos' 14import {
15 generateThumbnailFromUrl, getOrCreateAccountAndVideoAndChannel, videoActivityObjectToDBAttributes,
16 videoFileActivityUrlToDBAttributes
17} from '../videos'
15 18
16async function processUpdateActivity (activity: ActivityUpdate) { 19async function processUpdateActivity (activity: ActivityUpdate) {
17 const actor = await getOrCreateActorAndServerAndModel(activity.actor) 20 const actor = await getOrCreateActorAndServerAndModel(activity.actor)
@@ -82,6 +85,10 @@ async function updateRemoteVideo (actor: ActorModel, activity: ActivityUpdate) {
82 85
83 await videoInstance.save(sequelizeOptions) 86 await videoInstance.save(sequelizeOptions)
84 87
88 // Don't block on request
89 generateThumbnailFromUrl(videoInstance, videoAttributesToUpdate.icon)
90 .catch(err => logger.warn('Cannot generate thumbnail of %s.', videoAttributesToUpdate.id, err))
91
85 // Remove old video files 92 // Remove old video files
86 const videoFileDestroyTasks: Bluebird<void>[] = [] 93 const videoFileDestroyTasks: Bluebird<void>[] = []
87 for (const videoFile of videoInstance.VideoFiles) { 94 for (const videoFile of videoInstance.VideoFiles) {
diff --git a/server/middlewares/async.ts b/server/middlewares/async.ts
index 534891899..dd209b115 100644
--- a/server/middlewares/async.ts
+++ b/server/middlewares/async.ts
@@ -11,12 +11,12 @@ function asyncMiddleware (fun: RequestPromiseHandler | RequestPromiseHandler[])
11 if (Array.isArray(fun) === true) { 11 if (Array.isArray(fun) === true) {
12 return eachSeries(fun as RequestHandler[], (f, cb) => { 12 return eachSeries(fun as RequestHandler[], (f, cb) => {
13 Promise.resolve(f(req, res, cb)) 13 Promise.resolve(f(req, res, cb))
14 .catch(next) 14 .catch(err => next(err))
15 }, next) 15 }, next)
16 } 16 }
17 17
18 return Promise.resolve((fun as RequestHandler)(req, res, next)) 18 return Promise.resolve((fun as RequestHandler)(req, res, next))
19 .catch(next) 19 .catch(err => next(err))
20 } 20 }
21} 21}
22 22