]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/download.ts
Add bulk actions on runner jobs
[github/Chocobozzz/PeerTube.git] / server / controllers / download.ts
index d9f34109f360dc1cdf2477e1e56edff0af812b2c..d675a2d6cd4bfc56fc11664194be8c5beaaa155f 100644 (file)
@@ -5,7 +5,7 @@ import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache
 import { Hooks } from '@server/lib/plugins/hooks'
 import { VideoPathManager } from '@server/lib/video-path-manager'
 import { MStreamingPlaylist, MVideo, MVideoFile, MVideoFullLight } from '@server/types/models'
-import { addQueryParams } from '@shared/core-utils'
+import { addQueryParams, forceNumber } from '@shared/core-utils'
 import { HttpStatusCode, VideoStorage, VideoStreamingPlaylistType } from '@shared/models'
 import { STATIC_DOWNLOAD_PATHS } from '../initializers/constants'
 import { asyncMiddleware, optionalAuthenticate, videosDownloadValidator } from '../middlewares'
@@ -50,7 +50,12 @@ async function downloadTorrent (req: express.Request, res: express.Response) {
     })
   }
 
-  const allowParameters = { torrentPath: result.path, downloadName: result.downloadName }
+  const allowParameters = {
+    req,
+    res,
+    torrentPath: result.path,
+    downloadName: result.downloadName
+  }
 
   const allowedResult = await Hooks.wrapFun(
     isTorrentDownloadAllowed,
@@ -74,7 +79,12 @@ async function downloadVideoFile (req: express.Request, res: express.Response) {
     })
   }
 
-  const allowParameters = { video, videoFile }
+  const allowParameters = {
+    req,
+    res,
+    video,
+    videoFile
+  }
 
   const allowedResult = await Hooks.wrapFun(
     isVideoDownloadAllowed,
@@ -110,7 +120,13 @@ async function downloadHLSVideoFile (req: express.Request, res: express.Response
     })
   }
 
-  const allowParameters = { video, streamingPlaylist, videoFile }
+  const allowParameters = {
+    req,
+    res,
+    video,
+    streamingPlaylist,
+    videoFile
+  }
 
   const allowedResult = await Hooks.wrapFun(
     isVideoDownloadAllowed,
@@ -132,7 +148,7 @@ async function downloadHLSVideoFile (req: express.Request, res: express.Response
 }
 
 function getVideoFile (req: express.Request, files: MVideoFile[]) {
-  const resolution = parseInt(req.params.resolution, 10)
+  const resolution = forceNumber(req.params.resolution)
   return files.find(f => f.resolution === resolution)
 }