diff options
author | Chocobozzz <me@florianbigard.com> | 2021-02-16 16:25:53 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-02-18 13:38:09 +0100 |
commit | 90a8bd305de4153ec21137a73ff482dcc2e3e19b (patch) | |
tree | 2e35b5504ec11bc51579c92a70c77ed3d5ace816 /server/lib/schedulers/videos-redundancy-scheduler.ts | |
parent | 684cdacbbd775b5f404dd7b373e02dd21baf5ff0 (diff) | |
download | PeerTube-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.ts | 12 |
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' | |||
18 | import { logger } from '../../helpers/logger' | 18 | import { logger } from '../../helpers/logger' |
19 | import { downloadWebTorrentVideo, generateMagnetUri } from '../../helpers/webtorrent' | 19 | import { downloadWebTorrentVideo, generateMagnetUri } from '../../helpers/webtorrent' |
20 | import { CONFIG } from '../../initializers/config' | 20 | import { CONFIG } from '../../initializers/config' |
21 | import { HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT, WEBSERVER } from '../../initializers/constants' | 21 | import { HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT } from '../../initializers/constants' |
22 | import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' | 22 | import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' |
23 | import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send' | 23 | import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send' |
24 | import { getLocalVideoCacheFileActivityPubUrl, getLocalVideoCacheStreamingPlaylistActivityPubUrl } from '../activitypub/url' | 24 | import { getLocalVideoCacheFileActivityPubUrl, getLocalVideoCacheStreamingPlaylistActivityPubUrl } from '../activitypub/url' |
25 | import { getOrCreateVideoAndAccountAndChannel } from '../activitypub/videos' | 25 | import { getOrCreateVideoAndAccountAndChannel } from '../activitypub/videos' |
26 | import { downloadPlaylistSegments } from '../hls' | 26 | import { downloadPlaylistSegments } from '../hls' |
27 | import { removeVideoRedundancy } from '../redundancy' | 27 | import { removeVideoRedundancy } from '../redundancy' |
28 | import { getVideoFilename } from '../video-paths' | 28 | import { generateHLSRedundancyUrl, generateWebTorrentRedundancyUrl } from '../video-paths' |
29 | import { AbstractScheduler } from './abstract-scheduler' | 29 | import { AbstractScheduler } from './abstract-scheduler' |
30 | 30 | ||
31 | type CandidateToDuplicate = { | 31 | type 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 |