diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-06 12:26:58 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-02-06 12:26:58 +0100 |
commit | 73471b1a52f242e86364ffb077ea6cadb3b07ae2 (patch) | |
tree | 43dbb7748e281f8d80f15326f489cdea10ec857d /server/helpers/utils.ts | |
parent | c22419dd265c0c7185bf4197a1cb286eb3d8ebc0 (diff) | |
parent | f5305c04aae14467d6f957b713c5a902275cbb89 (diff) | |
download | PeerTube-73471b1a52f242e86364ffb077ea6cadb3b07ae2.tar.gz PeerTube-73471b1a52f242e86364ffb077ea6cadb3b07ae2.tar.zst PeerTube-73471b1a52f242e86364ffb077ea6cadb3b07ae2.zip |
Merge branch 'release/v1.2.0'
Diffstat (limited to 'server/helpers/utils.ts')
-rw-r--r-- | server/helpers/utils.ts | 12 |
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' | |||
7 | import { Instance as ParseTorrent } from 'parse-torrent' | 7 | import { Instance as ParseTorrent } from 'parse-torrent' |
8 | import { remove } from 'fs-extra' | 8 | import { remove } from 'fs-extra' |
9 | import * as memoizee from 'memoizee' | 9 | import * as memoizee from 'memoizee' |
10 | import { isArray } from './custom-validators/misc' | ||
10 | 11 | ||
11 | function deleteFileAsync (path: string) { | 12 | function 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 | ||
22 | interface FormattableToJSON { | 23 | interface FormattableToJSON { toFormattedJSON (args?: any) } |
23 | toFormattedJSON (args?: any) | ||
24 | } | ||
25 | |||
26 | function getFormattedObjects<U, T extends FormattableToJSON> (objects: T[], objectsTotal: number, formattedArg?: any) { | 24 | function 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 | ||
49 | function generateVideoTmpPath (target: string | ParseTorrent) { | 47 | function 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 | ||
56 | function getSecureTorrentName (originalName: string) { | 54 | function 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 | } |