X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=scripts%2Fmigrations%2Fpeertube-4.0.ts;h=b0891c2e638564051624e6521e8776992ced93d1;hb=4404a7c467a2c6863728127eeff5ca4b59619940;hp=387f6dc9c20b84a59321d08ecb0f4673fb601c75;hpb=e1ab52d7ec7370a6f9f5937192d6003206af1ac0;p=github%2FChocobozzz%2FPeerTube.git diff --git a/scripts/migrations/peertube-4.0.ts b/scripts/migrations/peertube-4.0.ts index 387f6dc9c..b0891c2e6 100644 --- a/scripts/migrations/peertube-4.0.ts +++ b/scripts/migrations/peertube-4.0.ts @@ -1,16 +1,13 @@ -import { registerTSPaths } from '../../server/helpers/register-ts-paths' -registerTSPaths() - +import Bluebird from 'bluebird' +import { move, readFile, writeFile } from 'fs-extra' import { join } from 'path' +import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' import { JobQueue } from '@server/lib/job-queue' -import { initDatabaseModels } from '../../server/initializers/database' import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getHlsResolutionPlaylistFilename } from '@server/lib/paths' import { VideoPathManager } from '@server/lib/video-path-manager' import { VideoModel } from '@server/models/video/video' import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' -import { move, readFile, writeFile } from 'fs-extra' -import Bluebird from 'bluebird' -import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' +import { initDatabaseModels } from '../../server/initializers/database' run() .then(() => process.exit(0)) @@ -24,7 +21,7 @@ async function run () { await initDatabaseModels(true) - JobQueue.Instance.init(true) + JobQueue.Instance.init() const ids = await VideoModel.listLocalIds() @@ -43,7 +40,7 @@ async function processVideo (videoId: number) { const video = await VideoModel.loadWithFiles(videoId) const hls = video.getHLSPlaylist() - if (!hls || hls.playlistFilename !== 'master.m3u8' || hls.VideoFiles.length === 0) { + if (video.isLive || !hls || hls.playlistFilename !== 'master.m3u8' || hls.VideoFiles.length === 0) { return } @@ -100,7 +97,7 @@ async function processVideo (videoId: number) { // Everything worked, we can save the playlist now await playlist.save() - const allVideo = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.id) + const allVideo = await VideoModel.loadFull(video.id) await federateVideoIfNeeded(allVideo, false) console.log(`Successfully moved HLS files of ${video.name}.`)