From b38e7d3078940b36a7302a09ff14e10a91a09fc1 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Tue, 13 Dec 2016 12:43:57 +0000 Subject: [PATCH] * delete both file and converted file if there is an error * increase timeout of optpng --- services/filestore/app/coffee/FileHandler.coffee | 6 ++++-- services/filestore/app/coffee/ImageOptimiser.coffee | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/services/filestore/app/coffee/FileHandler.coffee b/services/filestore/app/coffee/FileHandler.coffee index 718195a484..e0680aec3f 100644 --- a/services/filestore/app/coffee/FileHandler.coffee +++ b/services/filestore/app/coffee/FileHandler.coffee @@ -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 diff --git a/services/filestore/app/coffee/ImageOptimiser.coffee b/services/filestore/app/coffee/ImageOptimiser.coffee index be3fed1ca2..33c8cc8d56 100644 --- a/services/filestore/app/coffee/ImageOptimiser.coffee +++ b/services/filestore/app/coffee/ImageOptimiser.coffee @@ -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?