+import { CONFIG } from '../initializers/config'
+import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION } from '../initializers/constants'
+import { sequelizeTypescript } from '../initializers/database'
+import { VideoFileModel } from '../models/video/video-file'
+import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist'
+import { getVideoFilename, getVideoFilePath } from './video-paths'
+
+async function updateStreamingPlaylistsInfohashesIfNeeded () {
+ const playlistsToUpdate = await VideoStreamingPlaylistModel.listByIncorrectPeerVersion()
+
+ // Use separate SQL queries, because we could have many videos to update
+ for (const playlist of playlistsToUpdate) {
+ await sequelizeTypescript.transaction(async t => {
+ const videoFiles = await VideoFileModel.listByStreamingPlaylist(playlist.id, t)