aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-01-19 16:28:55 +0100
committerChocobozzz <me@florianbigard.com>2021-01-19 16:36:21 +0100
commit805b8619c1b8c56e08c927d93293c06e1075b50d (patch)
treea165d9929c0864ecdbf2ac6e07000ac266aa5d59 /server/helpers/utils.ts
parentd487a997c80fafe6067016c6cd8e8afd6141baa3 (diff)
downloadPeerTube-805b8619c1b8c56e08c927d93293c06e1075b50d.tar.gz
PeerTube-805b8619c1b8c56e08c927d93293c06e1075b50d.tar.zst
PeerTube-805b8619c1b8c56e08c927d93293c06e1075b50d.zip
Fix (again) youtube import
Diffstat (limited to 'server/helpers/utils.ts')
-rw-r--r--server/helpers/utils.ts16
1 files changed, 5 insertions, 11 deletions
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts
index ad3b7949e..0545e8996 100644
--- a/server/helpers/utils.ts
+++ b/server/helpers/utils.ts
@@ -1,11 +1,10 @@
1import { remove } from 'fs-extra'
2import { Instance as ParseTorrent } from 'parse-torrent'
3import { join } from 'path'
1import { ResultList } from '../../shared' 4import { ResultList } from '../../shared'
5import { CONFIG } from '../initializers/config'
2import { execPromise, execPromise2, randomBytesPromise, sha256 } from './core-utils' 6import { execPromise, execPromise2, randomBytesPromise, sha256 } from './core-utils'
3import { logger } from './logger' 7import { logger } from './logger'
4import { join } from 'path'
5import { Instance as ParseTorrent } from 'parse-torrent'
6import { remove } from 'fs-extra'
7import { CONFIG } from '../initializers/config'
8import { isVideoFileExtnameValid } from './custom-validators/videos'
9 8
10function deleteFileAsync (path: string) { 9function deleteFileAsync (path: string) {
11 remove(path) 10 remove(path)
@@ -31,16 +30,11 @@ function getFormattedObjects<U, V, T extends FormattableToJSON<U, V>> (objects:
31 } as ResultList<V> 30 } as ResultList<V>
32} 31}
33 32
34function generateVideoImportTmpPath (target: string | ParseTorrent, extensionArg?: string) { 33function generateVideoImportTmpPath (target: string | ParseTorrent, extension = '.mp4') {
35 const id = typeof target === 'string' 34 const id = typeof target === 'string'
36 ? target 35 ? target
37 : target.infoHash 36 : target.infoHash
38 37
39 let extension = '.mp4'
40 if (extensionArg && isVideoFileExtnameValid(extensionArg)) {
41 extension = extensionArg
42 }
43
44 const hash = sha256(id) 38 const hash = sha256(id)
45 return join(CONFIG.STORAGE.TMP_DIR, `${hash}-import${extension}`) 39 return join(CONFIG.STORAGE.TMP_DIR, `${hash}-import${extension}`)
46} 40}