import * as Bluebird from 'bluebird'
import { createWriteStream, remove } from 'fs-extra'
import * as request from 'request'
-import { ACTIVITY_PUB } from '../initializers'
+import { ACTIVITY_PUB } from '../initializers/constants'
import { processImage } from './image-utils'
import { join } from 'path'
import { logger } from './logger'
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
+ }
}
// ---------------------------------------------------------------------------