From 745778256ced65415b04a9817fc49db70d4b6681 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 4 Dec 2018 15:12:54 +0100 Subject: Fix thumbnail processing --- server/helpers/requests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'server/helpers/requests.ts') diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index 805930a9f..5760ad1c1 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts @@ -3,6 +3,7 @@ import { createWriteStream } from 'fs-extra' import * as request from 'request' import { ACTIVITY_PUB } from '../initializers' import { processImage } from './image-utils' +import { extname } from 'path' function doRequest ( requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean } @@ -29,8 +30,7 @@ function doRequestAndSaveToFile (requestOptions: request.CoreOptions & request.U } async function downloadImage (url: string, destPath: string, size: { width: number, height: number }) { - const tmpPath = destPath + '.tmp' - + const tmpPath = destPath + '.tmp' + extname(destPath) await doRequestAndSaveToFile({ method: 'GET', uri: url }, tmpPath) await processImage({ path: tmpPath }, destPath, size) -- cgit v1.2.3 From 6040f87d143a5fa01db79867ece8197c3ce7be47 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 4 Dec 2018 16:02:49 +0100 Subject: Add tmp and redundancy directories --- server/helpers/requests.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'server/helpers/requests.ts') diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index 5760ad1c1..3fc776f1a 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts @@ -1,9 +1,9 @@ import * as Bluebird from 'bluebird' import { createWriteStream } from 'fs-extra' import * as request from 'request' -import { ACTIVITY_PUB } from '../initializers' +import { ACTIVITY_PUB, CONFIG } from '../initializers' import { processImage } from './image-utils' -import { extname } from 'path' +import { join } from 'path' function doRequest ( requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean } @@ -29,10 +29,11 @@ function doRequestAndSaveToFile (requestOptions: request.CoreOptions & request.U }) } -async function downloadImage (url: string, destPath: string, size: { width: number, height: number }) { - const tmpPath = destPath + '.tmp' + extname(destPath) +async function downloadImage (url: string, destDir: string, destName: string, size: { width: number, height: number }) { + const tmpPath = join(CONFIG.STORAGE.TMP_DIR, 'pending-' + destName) await doRequestAndSaveToFile({ method: 'GET', uri: url }, tmpPath) + const destPath = join(destDir, destName) await processImage({ path: tmpPath }, destPath, size) } -- cgit v1.2.3