diff options
author | Chocobozzz <me@florianbigard.com> | 2021-09-06 09:29:25 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-09-06 16:19:49 +0200 |
commit | 02b286f89088e07cac7e7068e884d3be0fd0098b (patch) | |
tree | c98e159e6ee4512bb7026d052f565fcecc840124 /server/lib/schedulers/videos-redundancy-scheduler.ts | |
parent | 70430c2796b6c0455a863edc62760a3d45951fc5 (diff) | |
download | PeerTube-02b286f89088e07cac7e7068e884d3be0fd0098b.tar.gz PeerTube-02b286f89088e07cac7e7068e884d3be0fd0098b.tar.zst PeerTube-02b286f89088e07cac7e7068e884d3be0fd0098b.zip |
More robust webtorrent redundancy download
Avoid issues with inconsistencies between magnet infohash and torrent
infohash, blocking webtorrent upload that will timeout
Diffstat (limited to 'server/lib/schedulers/videos-redundancy-scheduler.ts')
-rw-r--r-- | server/lib/schedulers/videos-redundancy-scheduler.ts | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts index 633cbcf6c..155d43343 100644 --- a/server/lib/schedulers/videos-redundancy-scheduler.ts +++ b/server/lib/schedulers/videos-redundancy-scheduler.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import { move } from 'fs-extra' | 1 | import { move } from 'fs-extra' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { getServerActor } from '@server/models/application/application' | 3 | import { getServerActor } from '@server/models/application/application' |
4 | import { TrackerModel } from '@server/models/server/tracker' | ||
5 | import { VideoModel } from '@server/models/video/video' | 4 | import { VideoModel } from '@server/models/video/video' |
6 | import { | 5 | import { |
7 | MStreamingPlaylistFiles, | 6 | MStreamingPlaylistFiles, |
@@ -15,7 +14,7 @@ import { | |||
15 | } from '@server/types/models' | 14 | } from '@server/types/models' |
16 | import { VideosRedundancyStrategy } from '../../../shared/models/redundancy' | 15 | import { VideosRedundancyStrategy } from '../../../shared/models/redundancy' |
17 | import { logger, loggerTagsFactory } from '../../helpers/logger' | 16 | import { logger, loggerTagsFactory } from '../../helpers/logger' |
18 | import { downloadWebTorrentVideo, generateMagnetUri } from '../../helpers/webtorrent' | 17 | import { downloadWebTorrentVideo } from '../../helpers/webtorrent' |
19 | import { CONFIG } from '../../initializers/config' | 18 | import { CONFIG } from '../../initializers/config' |
20 | import { HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT } from '../../initializers/constants' | 19 | import { HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT } from '../../initializers/constants' |
21 | import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' | 20 | import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' |
@@ -232,10 +231,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler { | |||
232 | 231 | ||
233 | logger.info('Duplicating %s - %d in videos redundancy with "%s" strategy.', video.url, file.resolution, strategy, lTags(video.uuid)) | 232 | logger.info('Duplicating %s - %d in videos redundancy with "%s" strategy.', video.url, file.resolution, strategy, lTags(video.uuid)) |
234 | 233 | ||
235 | const trackerUrls = await TrackerModel.listUrlsByVideoId(video.id) | 234 | const tmpPath = await downloadWebTorrentVideo({ uri: file.torrentUrl }, VIDEO_IMPORT_TIMEOUT) |
236 | const magnetUri = generateMagnetUri(video, file, trackerUrls) | ||
237 | |||
238 | const tmpPath = await downloadWebTorrentVideo({ magnetUri }, VIDEO_IMPORT_TIMEOUT) | ||
239 | 235 | ||
240 | const destPath = join(CONFIG.STORAGE.REDUNDANCY_DIR, file.filename) | 236 | const destPath = join(CONFIG.STORAGE.REDUNDANCY_DIR, file.filename) |
241 | await move(tmpPath, destPath, { overwrite: true }) | 237 | await move(tmpPath, destPath, { overwrite: true }) |