From d7a25329f9e607894d29ab342b9cb66638b56dc0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 15 Nov 2019 15:06:03 +0100 Subject: Add ability to disable webtorrent In favour of HLS --- server/controllers/api/videos/index.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'server/controllers/api/videos') diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 0d1fbc8f4..78948ff24 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -64,6 +64,8 @@ import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' import { VideoTranscodingPayload } from '../../../lib/job-queue/handlers/video-transcoding' import { Hooks } from '../../../lib/plugins/hooks' import { MVideoDetails, MVideoFullLight } from '@server/typings/models' +import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' +import { getVideoFilename, getVideoFilePath } from '@server/lib/video-paths' const auditLogger = auditLoggerFactory('videos') const videosRouter = express.Router() @@ -203,7 +205,8 @@ async function addVideo (req: express.Request, res: express.Response) { const videoFile = new VideoFileModel({ extname: extname(videoPhysicalFile.filename), - size: videoPhysicalFile.size + size: videoPhysicalFile.size, + videoStreamingPlaylistId: null }) if (videoFile.isAudio()) { @@ -214,11 +217,10 @@ async function addVideo (req: express.Request, res: express.Response) { } // Move physical file - const videoDir = CONFIG.STORAGE.VIDEOS_DIR - const destination = join(videoDir, video.getVideoFilename(videoFile)) + const destination = getVideoFilePath(video, videoFile) await move(videoPhysicalFile.path, destination) // This is important in case if there is another attempt in the retry process - videoPhysicalFile.filename = video.getVideoFilename(videoFile) + videoPhysicalFile.filename = getVideoFilePath(video, videoFile) videoPhysicalFile.path = destination // Process thumbnail or create it from the video @@ -234,7 +236,7 @@ async function addVideo (req: express.Request, res: express.Response) { : await generateVideoMiniature(video, videoFile, ThumbnailType.PREVIEW) // Create the torrent file - await video.createTorrentAndSetInfoHash(videoFile) + await createTorrentAndSetInfoHash(video, videoFile) const { videoCreated } = await sequelizeTypescript.transaction(async t => { const sequelizeOptions = { transaction: t } -- cgit v1.2.3