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

Update torrent metadata on video update

This commit is contained in:
Chocobozzz 2021-12-08 11:07:19 +01:00
parent a23f6c94ed
commit 9b293cd6a2
No known key found for this signature in database
GPG key ID: 583A612D890159BE
7 changed files with 42 additions and 13 deletions

View file

@ -1,5 +1,6 @@
import express from 'express'
import { Transaction } from 'sequelize/types'
import { updateTorrentMetadata } from '@server/helpers/webtorrent'
import { changeVideoChannelShare } from '@server/lib/activitypub/share'
import { buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video'
import { openapiOperationDoc } from '@server/middlewares/doc'
@ -149,9 +150,8 @@ async function updateVideo (req: express.Request, res: express.Response) {
return videoInstanceUpdated
})
if (wasConfidentialVideo) {
Notifier.Instance.notifyOnNewVideoIfNeeded(videoInstanceUpdated)
}
if (videoInfoToUpdate.name) await updateTorrentsMetadata(videoInstanceUpdated)
if (wasConfidentialVideo) Notifier.Instance.notifyOnNewVideoIfNeeded(videoInstanceUpdated)
Hooks.runAction('action:api.video.updated', { video: videoInstanceUpdated, body: req.body, req, res })
} catch (err) {
@ -199,3 +199,9 @@ function updateSchedule (videoInstance: MVideoFullLight, videoInfoToUpdate: Vide
return ScheduleVideoUpdateModel.deleteByVideoId(videoInstance.id, transaction)
}
}
async function updateTorrentsMetadata (video: MVideoFullLight) {
for (const file of video.getAllFiles()) {
await updateTorrentMetadata(video, file)
}
}