Просмотр исходного кода

* delete both file and converted file if there is an error
* increase timeout of optpng

Henry Oswald 9 лет назад
Родитель
Сommit
b38e7d3078

+ 4 - 2
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

+ 1 - 1
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?