]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/utils.ts
Import magnets with webtorrent
[github/Chocobozzz/PeerTube.git] / server / helpers / utils.ts
index 7abcec5d727fe3f08ea7607d755cfe92a01fcc66..f4cc5547d49ddacbb1b57f4d528c13a6b584fabf 100644 (file)
@@ -9,6 +9,8 @@ import { ApplicationModel } from '../models/application/application'
 import { pseudoRandomBytesPromise, unlinkPromise } from './core-utils'
 import { logger } from './logger'
 import { isArray } from './custom-validators/misc'
+import * as crypto from "crypto"
+import { join } from "path"
 
 const isCidr = require('is-cidr')
 
@@ -181,8 +183,14 @@ async function getServerActor () {
   return Promise.resolve(serverActor)
 }
 
+function generateVideoTmpPath (id: string) {
+  const hash = crypto.createHash('sha256').update(id).digest('hex')
+  return join(CONFIG.STORAGE.VIDEOS_DIR, hash + '-import.mp4')
+}
+
 type SortType = { sortModel: any, sortValue: string }
 
+
 // ---------------------------------------------------------------------------
 
 export {
@@ -195,5 +203,6 @@ export {
   computeResolutionsToTranscode,
   resetSequelizeInstance,
   getServerActor,
-  SortType
+  SortType,
+  generateVideoTmpPath
 }