Commit fa8bae3e authored by Isabella Skořepová's avatar Isabella Skořepová

Fix race condition in imageResizer

parent 5e1dd667
Pipeline #402 passed with stages
in 1 minute and 39 seconds
......@@ -8,6 +8,8 @@ catch(e) {
console.log('You can try to run npm install.');
console.log('If it does not help try to make npm install lwip work.');
}
var mkdirp = require('mkdirp');
var path = require('path');
module.exports = function(file, targetDir, width, height) {
if(lwip && (width || height)) {
......@@ -23,11 +25,13 @@ module.exports = function(file, targetDir, width, height) {
targetFile = path.resolve(targetDir,targetFile);
lwip.open(file, function(err, image) {
function doResize() {
image.batch()
.resize(width, height)
.writeFile(targetFile, function(err) {
if(err) console.log(err);
});
mkdirp(path.dirname(targetFile), function() {
image.batch()
.resize(width, height)
.writeFile(targetFile, function(err) {
if(err) console.log(err);
});
}
}
if(err) return console.log(err);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment