diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-24 09:56:25 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-24 16:26:22 +0200 |
commit | 2fb5b3a55aeebcc77f4b3a0c029bbf0738ef0063 (patch) | |
tree | 3f03677870548c648070ac138a2b5ca36ee8fbeb /server/helpers/image-utils.ts | |
parent | b876eaf11a1ed9683664d94767ca684ba5b77753 (diff) | |
download | PeerTube-2fb5b3a55aeebcc77f4b3a0c029bbf0738ef0063.tar.gz PeerTube-2fb5b3a55aeebcc77f4b3a0c029bbf0738ef0063.tar.zst PeerTube-2fb5b3a55aeebcc77f4b3a0c029bbf0738ef0063.zip |
Relax videos list thumbnail api join
Diffstat (limited to 'server/helpers/image-utils.ts')
-rw-r--r-- | server/helpers/image-utils.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/server/helpers/image-utils.ts b/server/helpers/image-utils.ts index eeaef0f5d..bd81aa3ba 100644 --- a/server/helpers/image-utils.ts +++ b/server/helpers/image-utils.ts | |||
@@ -4,19 +4,19 @@ import { readFile, remove } from 'fs-extra' | |||
4 | import { logger } from './logger' | 4 | import { logger } from './logger' |
5 | 5 | ||
6 | async function processImage ( | 6 | async function processImage ( |
7 | physicalFile: { path: string }, | 7 | path: string, |
8 | destination: string, | 8 | destination: string, |
9 | newSize: { width: number, height: number }, | 9 | newSize: { width: number, height: number }, |
10 | keepOriginal = false | 10 | keepOriginal = false |
11 | ) { | 11 | ) { |
12 | if (physicalFile.path === destination) { | 12 | if (path === destination) { |
13 | throw new Error('Sharp needs an input path different that the output path.') | 13 | throw new Error('Sharp needs an input path different that the output path.') |
14 | } | 14 | } |
15 | 15 | ||
16 | logger.debug('Processing image %s to %s.', physicalFile.path, destination) | 16 | logger.debug('Processing image %s to %s.', path, destination) |
17 | 17 | ||
18 | // Avoid sharp cache | 18 | // Avoid sharp cache |
19 | const buf = await readFile(physicalFile.path) | 19 | const buf = await readFile(path) |
20 | const sharpInstance = sharp(buf) | 20 | const sharpInstance = sharp(buf) |
21 | 21 | ||
22 | await remove(destination) | 22 | await remove(destination) |
@@ -25,7 +25,7 @@ async function processImage ( | |||
25 | .resize(newSize.width, newSize.height) | 25 | .resize(newSize.width, newSize.height) |
26 | .toFile(destination) | 26 | .toFile(destination) |
27 | 27 | ||
28 | if (keepOriginal !== true) await remove(physicalFile.path) | 28 | if (keepOriginal !== true) await remove(path) |
29 | } | 29 | } |
30 | 30 | ||
31 | // --------------------------------------------------------------------------- | 31 | // --------------------------------------------------------------------------- |