diff options
author | Chocobozzz <me@florianbigard.com> | 2018-10-01 12:00:05 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-10-01 12:00:05 +0200 |
commit | cf9166cf2fb7b51a1137a259eed9338798c73500 (patch) | |
tree | 7cf4b5995d4a29cc335e1fd72c1572510f8432ad /server/lib | |
parent | 2a27c451f78922107c3f056e7506be8a79b31e03 (diff) | |
download | PeerTube-cf9166cf2fb7b51a1137a259eed9338798c73500.tar.gz PeerTube-cf9166cf2fb7b51a1137a259eed9338798c73500.tar.zst PeerTube-cf9166cf2fb7b51a1137a259eed9338798c73500.zip |
Add timeout on youtube dl to cleaup files
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/job-queue/handlers/video-import.ts | 6 | ||||
-rw-r--r-- | server/lib/schedulers/videos-redundancy-scheduler.ts | 5 |
2 files changed, 5 insertions, 6 deletions
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index 8f237dd91..e3f2a276c 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts | |||
@@ -6,7 +6,7 @@ import { VideoImportState } from '../../../../shared/models/videos' | |||
6 | import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' | 6 | import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' |
7 | import { extname, join } from 'path' | 7 | import { extname, join } from 'path' |
8 | import { VideoFileModel } from '../../../models/video/video-file' | 8 | import { VideoFileModel } from '../../../models/video/video-file' |
9 | import { CONFIG, sequelizeTypescript } from '../../../initializers' | 9 | import { CONFIG, sequelizeTypescript, VIDEO_IMPORT_TIMEOUT } from '../../../initializers' |
10 | import { doRequestAndSaveToFile } from '../../../helpers/requests' | 10 | import { doRequestAndSaveToFile } from '../../../helpers/requests' |
11 | import { VideoState } from '../../../../shared' | 11 | import { VideoState } from '../../../../shared' |
12 | import { JobQueue } from '../index' | 12 | import { JobQueue } from '../index' |
@@ -65,7 +65,7 @@ async function processTorrentImport (job: Bull.Job, payload: VideoImportTorrentP | |||
65 | torrentName: videoImport.torrentName ? getSecureTorrentName(videoImport.torrentName) : undefined, | 65 | torrentName: videoImport.torrentName ? getSecureTorrentName(videoImport.torrentName) : undefined, |
66 | magnetUri: videoImport.magnetUri | 66 | magnetUri: videoImport.magnetUri |
67 | } | 67 | } |
68 | return processFile(() => downloadWebTorrentVideo(target), videoImport, options) | 68 | return processFile(() => downloadWebTorrentVideo(target, VIDEO_IMPORT_TIMEOUT), videoImport, options) |
69 | } | 69 | } |
70 | 70 | ||
71 | async function processYoutubeDLImport (job: Bull.Job, payload: VideoImportYoutubeDLPayload) { | 71 | async function processYoutubeDLImport (job: Bull.Job, payload: VideoImportYoutubeDLPayload) { |
@@ -83,7 +83,7 @@ async function processYoutubeDLImport (job: Bull.Job, payload: VideoImportYoutub | |||
83 | generatePreview: false | 83 | generatePreview: false |
84 | } | 84 | } |
85 | 85 | ||
86 | return processFile(() => downloadYoutubeDLVideo(videoImport.targetUrl), videoImport, options) | 86 | return processFile(() => downloadYoutubeDLVideo(videoImport.targetUrl, VIDEO_IMPORT_TIMEOUT), videoImport, options) |
87 | } | 87 | } |
88 | 88 | ||
89 | async function getVideoImportOrDie (videoImportId: number) { | 89 | async function getVideoImportOrDie (videoImportId: number) { |
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts index 11ee05a53..432bade1f 100644 --- a/server/lib/schedulers/videos-redundancy-scheduler.ts +++ b/server/lib/schedulers/videos-redundancy-scheduler.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { AbstractScheduler } from './abstract-scheduler' | 1 | import { AbstractScheduler } from './abstract-scheduler' |
2 | import { CONFIG, JOB_TTL, REDUNDANCY } from '../../initializers' | 2 | import { CONFIG, REDUNDANCY, VIDEO_IMPORT_TIMEOUT } from '../../initializers' |
3 | import { logger } from '../../helpers/logger' | 3 | import { logger } from '../../helpers/logger' |
4 | import { VideosRedundancy } from '../../../shared/models/redundancy' | 4 | import { VideosRedundancy } from '../../../shared/models/redundancy' |
5 | import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' | 5 | import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' |
@@ -9,7 +9,6 @@ import { join } from 'path' | |||
9 | import { rename } from 'fs-extra' | 9 | import { rename } from 'fs-extra' |
10 | import { getServerActor } from '../../helpers/utils' | 10 | import { getServerActor } from '../../helpers/utils' |
11 | import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send' | 11 | import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send' |
12 | import { VideoModel } from '../../models/video/video' | ||
13 | import { getVideoCacheFileActivityPubUrl } from '../activitypub/url' | 12 | import { getVideoCacheFileActivityPubUrl } from '../activitypub/url' |
14 | import { removeVideoRedundancy } from '../redundancy' | 13 | import { removeVideoRedundancy } from '../redundancy' |
15 | import { getOrCreateVideoAndAccountAndChannel } from '../activitypub' | 14 | import { getOrCreateVideoAndAccountAndChannel } from '../activitypub' |
@@ -142,7 +141,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler { | |||
142 | const { baseUrlHttp, baseUrlWs } = video.getBaseUrls() | 141 | const { baseUrlHttp, baseUrlWs } = video.getBaseUrls() |
143 | const magnetUri = video.generateMagnetUri(file, baseUrlHttp, baseUrlWs) | 142 | const magnetUri = video.generateMagnetUri(file, baseUrlHttp, baseUrlWs) |
144 | 143 | ||
145 | const tmpPath = await downloadWebTorrentVideo({ magnetUri }, JOB_TTL['video-import']) | 144 | const tmpPath = await downloadWebTorrentVideo({ magnetUri }, VIDEO_IMPORT_TIMEOUT) |
146 | 145 | ||
147 | const destPath = join(CONFIG.STORAGE.VIDEOS_DIR, video.getVideoFilename(file)) | 146 | const destPath = join(CONFIG.STORAGE.VIDEOS_DIR, video.getVideoFilename(file)) |
148 | await rename(tmpPath, destPath) | 147 | await rename(tmpPath, destPath) |