* delete both file and converted file if there is an error

* increase timeout of optpng
This commit is contained in:
Henry Oswald 2016-12-13 12:43:57 +00:00
parent 4064956cea
commit b38e7d3078
2 changed files with 5 additions and 3 deletions

View file

@ -49,7 +49,7 @@ module.exports =
convertedFsPath = ""
async.series [
(cb) =>
@_convertFile bucket, key, opts, (err, fileSystemPath) ->
@_convertFile bucket, key, opts, (err, fileSystemPath, originalFsPath) ->
convertedFsPath = fileSystemPath
cb err
(cb)->
@ -58,6 +58,8 @@ module.exports =
PersistorManager.sendFile bucket, convertedKey, convertedFsPath, cb
], (err)->
if err?
LocalFileWriter.deleteFile convertedFsPath, ->
LocalFileWriter.deleteFile originalFsPath, ->
return callback(err)
PersistorManager.getFileStream bucket, convertedKey, opts, callback
@ -70,7 +72,7 @@ module.exports =
logger.err err:err, bucket:bucket, originalKey:originalKey, opts:opts, "error converting file"
return callback(err)
LocalFileWriter.deleteFile originalFsPath, ->
callback(err, destPath)
callback(err, destPath, originalFsPath)
if opts.format?
FileConverter.convert originalFsPath, opts.format, done

View file

@ -8,7 +8,7 @@ module.exports =
logger.log localPath:localPath, "optimising png path"
args = "optipng #{localPath}"
opts =
timeout: 20 * 1000
timeout: 30 * 1000
killSignal: "SIGKILL"
exec args, opts,(err, stdout, stderr)->
if err?