1
0
Fork 0
mirror of https://github.com/overleaf/overleaf.git synced 2025-02-20 04:44:04 +00:00

Merge pull request from sharelatex/deletefailedfiles

* delete both file and converted file if there is an error
This commit is contained in:
Henry Oswald 2016-12-13 14:34:30 +00:00 committed by GitHub
commit 8b4911625c
2 changed files with 7 additions and 3 deletions
services/filestore/app/coffee

View file

@ -47,10 +47,12 @@ module.exports =
_getConvertedFileAndCache: (bucket, key, convertedKey, opts, callback)->
convertedFsPath = ""
originalFsPath = ""
async.series [
(cb) =>
@_convertFile bucket, key, opts, (err, fileSystemPath) ->
@_convertFile bucket, key, opts, (err, fileSystemPath, originalFsPath) ->
convertedFsPath = fileSystemPath
originalFsPath = originalFsPath
cb err
(cb)->
ImageOptimiser.compressPng convertedFsPath, cb
@ -58,6 +60,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 +74,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?