aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/schedulers/videos-redundancy-scheduler.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-11-21 12:16:27 +0100
committerChocobozzz <me@florianbigard.com>2019-11-25 10:59:44 +0100
commit66fb2aa39b6f8e4677f80128c27fbafd3a8fe2e7 (patch)
tree9d2f21e81cc42d8d51ac7ae35d91c30f143f0be0 /server/lib/schedulers/videos-redundancy-scheduler.ts
parentd7a25329f9e607894d29ab342b9cb66638b56dc0 (diff)
downloadPeerTube-66fb2aa39b6f8e4677f80128c27fbafd3a8fe2e7.tar.gz
PeerTube-66fb2aa39b6f8e4677f80128c27fbafd3a8fe2e7.tar.zst
PeerTube-66fb2aa39b6f8e4677f80128c27fbafd3a8fe2e7.zip
Don't always replace actor avatar
Diffstat (limited to 'server/lib/schedulers/videos-redundancy-scheduler.ts')
-rw-r--r--server/lib/schedulers/videos-redundancy-scheduler.ts15
1 files changed, 9 insertions, 6 deletions
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts
index f2bd75cb4..c1c91b656 100644
--- a/server/lib/schedulers/videos-redundancy-scheduler.ts
+++ b/server/lib/schedulers/videos-redundancy-scheduler.ts
@@ -14,7 +14,7 @@ import { getOrCreateVideoAndAccountAndChannel } from '../activitypub'
14import { downloadPlaylistSegments } from '../hls' 14import { downloadPlaylistSegments } from '../hls'
15import { CONFIG } from '../../initializers/config' 15import { CONFIG } from '../../initializers/config'
16import { 16import {
17 MStreamingPlaylist, 17 MStreamingPlaylist, MStreamingPlaylistFiles,
18 MStreamingPlaylistVideo, 18 MStreamingPlaylistVideo,
19 MVideoAccountLight, 19 MVideoAccountLight,
20 MVideoFile, 20 MVideoFile,
@@ -30,7 +30,7 @@ type CandidateToDuplicate = {
30 redundancy: VideosRedundancy, 30 redundancy: VideosRedundancy,
31 video: MVideoWithAllFiles, 31 video: MVideoWithAllFiles,
32 files: MVideoFile[], 32 files: MVideoFile[],
33 streamingPlaylists: MStreamingPlaylist[] 33 streamingPlaylists: MStreamingPlaylistFiles[]
34} 34}
35 35
36function isMVideoRedundancyFileVideo ( 36function isMVideoRedundancyFileVideo (
@@ -196,7 +196,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
196 logger.info('Duplicating %s - %d in videos redundancy with "%s" strategy.', video.url, file.resolution, redundancy.strategy) 196 logger.info('Duplicating %s - %d in videos redundancy with "%s" strategy.', video.url, file.resolution, redundancy.strategy)
197 197
198 const { baseUrlHttp, baseUrlWs } = video.getBaseUrls() 198 const { baseUrlHttp, baseUrlWs } = video.getBaseUrls()
199 const magnetUri = await generateMagnetUri(video, file, baseUrlHttp, baseUrlWs) 199 const magnetUri = generateMagnetUri(video, file, baseUrlHttp, baseUrlWs)
200 200
201 const tmpPath = await downloadWebTorrentVideo({ magnetUri }, VIDEO_IMPORT_TIMEOUT) 201 const tmpPath = await downloadWebTorrentVideo({ magnetUri }, VIDEO_IMPORT_TIMEOUT)
202 202
@@ -290,12 +290,15 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
290 return `${object.VideoStreamingPlaylist.playlistUrl}` 290 return `${object.VideoStreamingPlaylist.playlistUrl}`
291 } 291 }
292 292
293 private getTotalFileSizes (files: MVideoFile[], playlists: MStreamingPlaylist[]) { 293 private getTotalFileSizes (files: MVideoFile[], playlists: MStreamingPlaylistFiles[]) {
294 const fileReducer = (previous: number, current: MVideoFile) => previous + current.size 294 const fileReducer = (previous: number, current: MVideoFile) => previous + current.size
295 295
296 const totalSize = files.reduce(fileReducer, 0) 296 let allFiles = files
297 for (const p of playlists) {
298 allFiles = allFiles.concat(p.VideoFiles)
299 }
297 300
298 return totalSize + (totalSize * playlists.length) 301 return allFiles.reduce(fileReducer, 0)
299 } 302 }
300 303
301 private async loadAndRefreshVideo (videoUrl: string) { 304 private async loadAndRefreshVideo (videoUrl: string) {