aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/requests.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-06-24 16:31:32 +0200
committerChocobozzz <me@florianbigard.com>2022-06-24 16:31:48 +0200
commitc53853ca1b8e32aea5259d436d3d284b9d178919 (patch)
treedfb081e7fb471ca4b75fd67eabd3216cc6b33129 /server/helpers/requests.ts
parent2873f00bd89d8f1b5f88614415f8142a5c2065c3 (diff)
downloadPeerTube-c53853ca1b8e32aea5259d436d3d284b9d178919.tar.gz
PeerTube-c53853ca1b8e32aea5259d436d3d284b9d178919.tar.zst
PeerTube-c53853ca1b8e32aea5259d436d3d284b9d178919.zip
Introduce worker threads to process remote images
Diffstat (limited to 'server/helpers/requests.ts')
-rw-r--r--server/helpers/requests.ts19
1 files changed, 0 insertions, 19 deletions
diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts
index a9869e987..495e83558 100644
--- a/server/helpers/requests.ts
+++ b/server/helpers/requests.ts
@@ -1,11 +1,8 @@
1import { createWriteStream, remove } from 'fs-extra' 1import { createWriteStream, remove } from 'fs-extra'
2import got, { CancelableRequest, NormalizedOptions, Options as GotOptions, RequestError, Response } from 'got' 2import got, { CancelableRequest, NormalizedOptions, Options as GotOptions, RequestError, Response } from 'got'
3import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent' 3import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent'
4import { join } from 'path'
5import { CONFIG } from '../initializers/config'
6import { ACTIVITY_PUB, BINARY_CONTENT_TYPES, PEERTUBE_VERSION, REQUEST_TIMEOUTS, WEBSERVER } from '../initializers/constants' 4import { ACTIVITY_PUB, BINARY_CONTENT_TYPES, PEERTUBE_VERSION, REQUEST_TIMEOUTS, WEBSERVER } from '../initializers/constants'
7import { pipelinePromise } from './core-utils' 5import { pipelinePromise } from './core-utils'
8import { processImage } from './image-utils'
9import { logger, loggerTagsFactory } from './logger' 6import { logger, loggerTagsFactory } from './logger'
10import { getProxy, isProxyEnabled } from './proxy' 7import { getProxy, isProxyEnabled } from './proxy'
11 8
@@ -147,21 +144,6 @@ async function doRequestAndSaveToFile (
147 } 144 }
148} 145}
149 146
150async function downloadImage (url: string, destDir: string, destName: string, size: { width: number, height: number }) {
151 const tmpPath = join(CONFIG.STORAGE.TMP_DIR, 'pending-' + destName)
152 await doRequestAndSaveToFile(url, tmpPath)
153
154 const destPath = join(destDir, destName)
155
156 try {
157 await processImage(tmpPath, destPath, size)
158 } catch (err) {
159 await remove(tmpPath)
160
161 throw err
162 }
163}
164
165function getAgent () { 147function getAgent () {
166 if (!isProxyEnabled()) return {} 148 if (!isProxyEnabled()) return {}
167 149
@@ -211,7 +193,6 @@ export {
211 doJSONRequest, 193 doJSONRequest,
212 doRequestAndSaveToFile, 194 doRequestAndSaveToFile,
213 isBinaryResponse, 195 isBinaryResponse,
214 downloadImage,
215 getAgent, 196 getAgent,
216 findLatestRedirection, 197 findLatestRedirection,
217 peertubeGot 198 peertubeGot