X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Frequests.ts;h=2e30c94a1e8ed2e53846bebb0e92c2fad9fc976f;hb=a41b9da1a9ce49df82ea10c82de4c2fbc6d1b189;hp=3762e4d3c5c2cf981766e757e1eae46a0af9305c;hpb=bfe2ef6bfae03444a232883fc7c449206cf3bee4;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index 3762e4d3c..2e30c94a1 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts @@ -1,10 +1,11 @@ import * as Bluebird from 'bluebird' import { createWriteStream, remove } from 'fs-extra' import * as request from 'request' -import { ACTIVITY_PUB, CONFIG } from '../initializers' +import { ACTIVITY_PUB } from '../initializers/constants' import { processImage } from './image-utils' import { join } from 'path' import { logger } from './logger' +import { CONFIG } from '../initializers/config' function doRequest ( requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean }, @@ -49,7 +50,14 @@ async function downloadImage (url: string, destDir: string, destName: string, si await doRequestAndSaveToFile({ method: 'GET', uri: url }, tmpPath) const destPath = join(destDir, destName) - await processImage({ path: tmpPath }, destPath, size) + + try { + await processImage(tmpPath, destPath, size) + } catch (err) { + await remove(tmpPath) + + throw err + } } // ---------------------------------------------------------------------------