diff options
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/api/videos/update.ts | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/server/controllers/api/videos/update.ts b/server/controllers/api/videos/update.ts index 6f14a6788..c0eb4ebee 100644 --- a/server/controllers/api/videos/update.ts +++ b/server/controllers/api/videos/update.ts | |||
@@ -69,7 +69,7 @@ async function updateVideo (req: express.Request, res: express.Response) { | |||
69 | }) | 69 | }) |
70 | 70 | ||
71 | try { | 71 | try { |
72 | const videoInstanceUpdated = await sequelizeTypescript.transaction(async t => { | 72 | const { videoInstanceUpdated, isNewVideo } = await sequelizeTypescript.transaction(async t => { |
73 | // Refresh video since thumbnails to prevent concurrent updates | 73 | // Refresh video since thumbnails to prevent concurrent updates |
74 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoFromReq.id, t) | 74 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoFromReq.id, t) |
75 | 75 | ||
@@ -138,8 +138,6 @@ async function updateVideo (req: express.Request, res: express.Response) { | |||
138 | transaction: t | 138 | transaction: t |
139 | }) | 139 | }) |
140 | 140 | ||
141 | await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t) | ||
142 | |||
143 | auditLogger.update( | 141 | auditLogger.update( |
144 | getAuditIdFromRes(res), | 142 | getAuditIdFromRes(res), |
145 | new VideoAuditView(videoInstanceUpdated.toFormattedDetailsJSON()), | 143 | new VideoAuditView(videoInstanceUpdated.toFormattedDetailsJSON()), |
@@ -147,10 +145,13 @@ async function updateVideo (req: express.Request, res: express.Response) { | |||
147 | ) | 145 | ) |
148 | logger.info('Video with name %s and uuid %s updated.', video.name, video.uuid, lTags(video.uuid)) | 146 | logger.info('Video with name %s and uuid %s updated.', video.name, video.uuid, lTags(video.uuid)) |
149 | 147 | ||
150 | return videoInstanceUpdated | 148 | return { videoInstanceUpdated, isNewVideo } |
151 | }) | 149 | }) |
152 | 150 | ||
153 | if (videoInfoToUpdate.name) await updateTorrentsMetadata(videoInstanceUpdated) | 151 | if (videoInfoToUpdate.name) await updateTorrentsMetadata(videoInstanceUpdated) |
152 | |||
153 | await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, undefined) | ||
154 | |||
154 | if (wasConfidentialVideo) Notifier.Instance.notifyOnNewVideoIfNeeded(videoInstanceUpdated) | 155 | if (wasConfidentialVideo) Notifier.Instance.notifyOnNewVideoIfNeeded(videoInstanceUpdated) |
155 | 156 | ||
156 | Hooks.runAction('action:api.video.updated', { video: videoInstanceUpdated, body: req.body, req, res }) | 157 | Hooks.runAction('action:api.video.updated', { video: videoInstanceUpdated, body: req.body, req, res }) |
@@ -203,5 +204,7 @@ function updateSchedule (videoInstance: MVideoFullLight, videoInfoToUpdate: Vide | |||
203 | async function updateTorrentsMetadata (video: MVideoFullLight) { | 204 | async function updateTorrentsMetadata (video: MVideoFullLight) { |
204 | for (const file of video.getAllFiles()) { | 205 | for (const file of video.getAllFiles()) { |
205 | await updateTorrentMetadata(video, file) | 206 | await updateTorrentMetadata(video, file) |
207 | |||
208 | await file.save() | ||
206 | } | 209 | } |
207 | } | 210 | } |