mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-05 23:29:00 +02:00
Merge pull request #22 from sharelatex/deletefailedfiles
* delete both file and converted file if there is an error
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user