-
-async function updateTorrentsMetadataIfNeeded (video: MVideoFullLight, videoInfoToUpdate: VideoUpdate) {
- if (video.isLive || !videoInfoToUpdate.name) return video
-
- for (const file of (video.VideoFiles || [])) {
- const payload: ManageVideoTorrentPayload = { action: 'update-metadata', videoId: video.id, videoFileId: file.id }
-
- const job = await JobQueue.Instance.createJobWithPromise({ type: 'manage-video-torrent', payload })
- await JobQueue.Instance.waitJob(job)
- }
-
- const hls = video.getHLSPlaylist()
-
- for (const file of (hls?.VideoFiles || [])) {
- const payload: ManageVideoTorrentPayload = { action: 'update-metadata', streamingPlaylistId: hls.id, videoFileId: file.id }
-
- const job = await JobQueue.Instance.createJobWithPromise({ type: 'manage-video-torrent', payload })
- await JobQueue.Instance.waitJob(job)
- }
-
- // Refresh video since files have changed
- return VideoModel.loadFull(video.id)
-}