aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/schedulers/videos-redundancy-scheduler.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-16 16:25:53 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-02-18 13:38:09 +0100
commit90a8bd305de4153ec21137a73ff482dcc2e3e19b (patch)
tree2e35b5504ec11bc51579c92a70c77ed3d5ace816 /server/lib/schedulers/videos-redundancy-scheduler.ts
parent684cdacbbd775b5f404dd7b373e02dd21baf5ff0 (diff)
downloadPeerTube-90a8bd305de4153ec21137a73ff482dcc2e3e19b.tar.gz
PeerTube-90a8bd305de4153ec21137a73ff482dcc2e3e19b.tar.zst
PeerTube-90a8bd305de4153ec21137a73ff482dcc2e3e19b.zip
Dissociate video file names and video uuid
Diffstat (limited to 'server/lib/schedulers/videos-redundancy-scheduler.ts')
-rw-r--r--server/lib/schedulers/videos-redundancy-scheduler.ts12
1 files changed, 6 insertions, 6 deletions
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts
index 93e76626c..60008e695 100644
--- a/server/lib/schedulers/videos-redundancy-scheduler.ts
+++ b/server/lib/schedulers/videos-redundancy-scheduler.ts
@@ -18,14 +18,14 @@ import { VideosRedundancyStrategy } from '../../../shared/models/redundancy'
18import { logger } from '../../helpers/logger' 18import { logger } from '../../helpers/logger'
19import { downloadWebTorrentVideo, generateMagnetUri } from '../../helpers/webtorrent' 19import { downloadWebTorrentVideo, generateMagnetUri } from '../../helpers/webtorrent'
20import { CONFIG } from '../../initializers/config' 20import { CONFIG } from '../../initializers/config'
21import { HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT, WEBSERVER } from '../../initializers/constants' 21import { HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT } from '../../initializers/constants'
22import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' 22import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
23import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send' 23import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send'
24import { getLocalVideoCacheFileActivityPubUrl, getLocalVideoCacheStreamingPlaylistActivityPubUrl } from '../activitypub/url' 24import { getLocalVideoCacheFileActivityPubUrl, getLocalVideoCacheStreamingPlaylistActivityPubUrl } from '../activitypub/url'
25import { getOrCreateVideoAndAccountAndChannel } from '../activitypub/videos' 25import { getOrCreateVideoAndAccountAndChannel } from '../activitypub/videos'
26import { downloadPlaylistSegments } from '../hls' 26import { downloadPlaylistSegments } from '../hls'
27import { removeVideoRedundancy } from '../redundancy' 27import { removeVideoRedundancy } from '../redundancy'
28import { getVideoFilename } from '../video-paths' 28import { generateHLSRedundancyUrl, generateWebTorrentRedundancyUrl } from '../video-paths'
29import { AbstractScheduler } from './abstract-scheduler' 29import { AbstractScheduler } from './abstract-scheduler'
30 30
31type CandidateToDuplicate = { 31type CandidateToDuplicate = {
@@ -222,17 +222,17 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
222 logger.info('Duplicating %s - %d in videos redundancy with "%s" strategy.', video.url, file.resolution, strategy) 222 logger.info('Duplicating %s - %d in videos redundancy with "%s" strategy.', video.url, file.resolution, strategy)
223 223
224 const { baseUrlHttp, baseUrlWs } = video.getBaseUrls() 224 const { baseUrlHttp, baseUrlWs } = video.getBaseUrls()
225 const magnetUri = generateMagnetUri(video, file, baseUrlHttp, baseUrlWs) 225 const magnetUri = generateMagnetUri(video, video, file, baseUrlHttp, baseUrlWs)
226 226
227 const tmpPath = await downloadWebTorrentVideo({ magnetUri }, VIDEO_IMPORT_TIMEOUT) 227 const tmpPath = await downloadWebTorrentVideo({ magnetUri }, VIDEO_IMPORT_TIMEOUT)
228 228
229 const destPath = join(CONFIG.STORAGE.REDUNDANCY_DIR, getVideoFilename(video, file)) 229 const destPath = join(CONFIG.STORAGE.REDUNDANCY_DIR, file.filename)
230 await move(tmpPath, destPath, { overwrite: true }) 230 await move(tmpPath, destPath, { overwrite: true })
231 231
232 const createdModel: MVideoRedundancyFileVideo = await VideoRedundancyModel.create({ 232 const createdModel: MVideoRedundancyFileVideo = await VideoRedundancyModel.create({
233 expiresOn, 233 expiresOn,
234 url: getLocalVideoCacheFileActivityPubUrl(file), 234 url: getLocalVideoCacheFileActivityPubUrl(file),
235 fileUrl: video.getVideoRedundancyUrl(file, WEBSERVER.URL), 235 fileUrl: generateWebTorrentRedundancyUrl(file),
236 strategy, 236 strategy,
237 videoFileId: file.id, 237 videoFileId: file.id,
238 actorId: serverActor.id 238 actorId: serverActor.id
@@ -271,7 +271,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
271 const createdModel: MVideoRedundancyStreamingPlaylistVideo = await VideoRedundancyModel.create({ 271 const createdModel: MVideoRedundancyStreamingPlaylistVideo = await VideoRedundancyModel.create({
272 expiresOn, 272 expiresOn,
273 url: getLocalVideoCacheStreamingPlaylistActivityPubUrl(video, playlist), 273 url: getLocalVideoCacheStreamingPlaylistActivityPubUrl(video, playlist),
274 fileUrl: playlist.getVideoRedundancyUrl(WEBSERVER.URL), 274 fileUrl: generateHLSRedundancyUrl(video, playlistArg),
275 strategy, 275 strategy,
276 videoStreamingPlaylistId: playlist.id, 276 videoStreamingPlaylistId: playlist.id,
277 actorId: serverActor.id 277 actorId: serverActor.id