aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/utils.ts')
-rw-r--r--server/helpers/utils.ts12
1 files changed, 5 insertions, 7 deletions
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts
index 5c9d6fe2f..3c3406e38 100644
--- a/server/helpers/utils.ts
+++ b/server/helpers/utils.ts
@@ -7,6 +7,7 @@ import { join } from 'path'
7import { Instance as ParseTorrent } from 'parse-torrent' 7import { Instance as ParseTorrent } from 'parse-torrent'
8import { remove } from 'fs-extra' 8import { remove } from 'fs-extra'
9import * as memoizee from 'memoizee' 9import * as memoizee from 'memoizee'
10import { isArray } from './custom-validators/misc'
10 11
11function deleteFileAsync (path: string) { 12function deleteFileAsync (path: string) {
12 remove(path) 13 remove(path)
@@ -19,10 +20,7 @@ async function generateRandomString (size: number) {
19 return raw.toString('hex') 20 return raw.toString('hex')
20} 21}
21 22
22interface FormattableToJSON { 23interface FormattableToJSON { toFormattedJSON (args?: any) }
23 toFormattedJSON (args?: any)
24}
25
26function getFormattedObjects<U, T extends FormattableToJSON> (objects: T[], objectsTotal: number, formattedArg?: any) { 24function getFormattedObjects<U, T extends FormattableToJSON> (objects: T[], objectsTotal: number, formattedArg?: any) {
27 const formattedObjects: U[] = [] 25 const formattedObjects: U[] = []
28 26
@@ -46,11 +44,11 @@ const getServerActor = memoizee(async function () {
46 return actor 44 return actor
47}) 45})
48 46
49function generateVideoTmpPath (target: string | ParseTorrent) { 47function generateVideoImportTmpPath (target: string | ParseTorrent) {
50 const id = typeof target === 'string' ? target : target.infoHash 48 const id = typeof target === 'string' ? target : target.infoHash
51 49
52 const hash = sha256(id) 50 const hash = sha256(id)
53 return join(CONFIG.STORAGE.VIDEOS_DIR, hash + '-import.mp4') 51 return join(CONFIG.STORAGE.TMP_DIR, hash + '-import.mp4')
54} 52}
55 53
56function getSecureTorrentName (originalName: string) { 54function getSecureTorrentName (originalName: string) {
@@ -103,6 +101,6 @@ export {
103 getSecureTorrentName, 101 getSecureTorrentName,
104 getServerActor, 102 getServerActor,
105 getServerCommit, 103 getServerCommit,
106 generateVideoTmpPath, 104 generateVideoImportTmpPath,
107 getUUIDFromFilename 105 getUUIDFromFilename
108} 106}