aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos/update.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-08 11:32:45 +0100
committerChocobozzz <me@florianbigard.com>2021-12-08 16:12:49 +0100
commit38d69d65012c8bf01bceb672be99f94fe414f275 (patch)
tree80ba6d43c4ce7ccff0c64d0c0817f43cc02a6531 /server/controllers/api/videos/update.ts
parent9b293cd6a2ce9ed1e1ccd41adbf7f2dbe2da8231 (diff)
downloadPeerTube-38d69d65012c8bf01bceb672be99f94fe414f275.tar.gz
PeerTube-38d69d65012c8bf01bceb672be99f94fe414f275.tar.zst
PeerTube-38d69d65012c8bf01bceb672be99f94fe414f275.zip
Update torrents info name on video update
Diffstat (limited to 'server/controllers/api/videos/update.ts')
-rw-r--r--server/controllers/api/videos/update.ts11
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
203async function updateTorrentsMetadata (video: MVideoFullLight) { 204async 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}