This is minor fix for image upload issue if multiple sub directories to be created based on permaLink of product

master
Shreyas 2018-12-23 15:03:09 +05:30 committed by Mark Moffat
parent 4739b59c1f
commit 1c09c0f7d4
1 changed files with 6 additions and 0 deletions

6
lib/common.js Normal file → Executable file
View File

@ -10,6 +10,7 @@ const async = require('async');
const nodemailer = require('nodemailer'); const nodemailer = require('nodemailer');
const sanitizeHtml = require('sanitize-html'); const sanitizeHtml = require('sanitize-html');
const escape = require('html-entities').AllHtmlEntities; const escape = require('html-entities').AllHtmlEntities;
const mkdirp = require('mkdirp');
let ObjectId = require('mongodb').ObjectID; let ObjectId = require('mongodb').ObjectID;
const restrictedRoutes = [ const restrictedRoutes = [
@ -177,8 +178,13 @@ exports.checkDirectorySync = (directory) => {
try{ try{
fs.statSync(directory); fs.statSync(directory);
}catch(e){ }catch(e){
try{
fs.mkdirSync(directory); fs.mkdirSync(directory);
} }
catch(err){
mkdirp.sync(directory);//error : directory & sub directories to be newly created
}
}
}; };
exports.getThemes = () => { exports.getThemes = () => {