1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Update torrents info name on video update

This commit is contained in:
Chocobozzz 2021-12-08 11:32:45 +01:00
parent 9b293cd6a2
commit 38d69d6501
No known key found for this signature in database
GPG key ID: 583A612D890159BE
4 changed files with 18 additions and 8 deletions

View file

@ -69,7 +69,7 @@ async function updateVideo (req: express.Request, res: express.Response) {
})
try {
const videoInstanceUpdated = await sequelizeTypescript.transaction(async t => {
const { videoInstanceUpdated, isNewVideo } = await sequelizeTypescript.transaction(async t => {
// Refresh video since thumbnails to prevent concurrent updates
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoFromReq.id, t)
@ -138,8 +138,6 @@ async function updateVideo (req: express.Request, res: express.Response) {
transaction: t
})
await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t)
auditLogger.update(
getAuditIdFromRes(res),
new VideoAuditView(videoInstanceUpdated.toFormattedDetailsJSON()),
@ -147,10 +145,13 @@ async function updateVideo (req: express.Request, res: express.Response) {
)
logger.info('Video with name %s and uuid %s updated.', video.name, video.uuid, lTags(video.uuid))
return videoInstanceUpdated
return { videoInstanceUpdated, isNewVideo }
})
if (videoInfoToUpdate.name) await updateTorrentsMetadata(videoInstanceUpdated)
await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, undefined)
if (wasConfidentialVideo) Notifier.Instance.notifyOnNewVideoIfNeeded(videoInstanceUpdated)
Hooks.runAction('action:api.video.updated', { video: videoInstanceUpdated, body: req.body, req, res })
@ -203,5 +204,7 @@ function updateSchedule (videoInstance: MVideoFullLight, videoInfoToUpdate: Vide
async function updateTorrentsMetadata (video: MVideoFullLight) {
for (const file of video.getAllFiles()) {
await updateTorrentMetadata(video, file)
await file.save()
}
}