aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-24 09:56:25 +0200
committerChocobozzz <me@florianbigard.com>2019-04-24 16:26:22 +0200
commit2fb5b3a55aeebcc77f4b3a0c029bbf0738ef0063 (patch)
tree3f03677870548c648070ac138a2b5ca36ee8fbeb /server/helpers
parentb876eaf11a1ed9683664d94767ca684ba5b77753 (diff)
downloadPeerTube-2fb5b3a55aeebcc77f4b3a0c029bbf0738ef0063.tar.gz
PeerTube-2fb5b3a55aeebcc77f4b3a0c029bbf0738ef0063.tar.zst
PeerTube-2fb5b3a55aeebcc77f4b3a0c029bbf0738ef0063.zip
Relax videos list thumbnail api join
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/ffmpeg-utils.ts2
-rw-r--r--server/helpers/image-utils.ts10
-rw-r--r--server/helpers/requests.ts2
3 files changed, 7 insertions, 7 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts
index d818c459c..76b744de8 100644
--- a/server/helpers/ffmpeg-utils.ts
+++ b/server/helpers/ffmpeg-utils.ts
@@ -105,7 +105,7 @@ async function generateImageFromVideoFile (fromPath: string, folder: string, ima
105 }) 105 })
106 106
107 const destination = join(folder, imageName) 107 const destination = join(folder, imageName)
108 await processImage({ path: pendingImagePath }, destination, size) 108 await processImage(pendingImagePath, destination, size)
109 } catch (err) { 109 } catch (err) {
110 logger.error('Cannot generate image from video %s.', fromPath, { err }) 110 logger.error('Cannot generate image from video %s.', fromPath, { err })
111 111
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'
4import { logger } from './logger' 4import { logger } from './logger'
5 5
6async function processImage ( 6async 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// ---------------------------------------------------------------------------
diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts
index 8dda6c039..2e30c94a1 100644
--- a/server/helpers/requests.ts
+++ b/server/helpers/requests.ts
@@ -52,7 +52,7 @@ async function downloadImage (url: string, destDir: string, destName: string, si
52 const destPath = join(destDir, destName) 52 const destPath = join(destDir, destName)
53 53
54 try { 54 try {
55 await processImage({ path: tmpPath }, destPath, size) 55 await processImage(tmpPath, destPath, size)
56 } catch (err) { 56 } catch (err) {
57 await remove(tmpPath) 57 await remove(tmpPath)
58 58