Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setUserDataPath: function(userId) {
var me = this;
// 判断是否存在, 不存在则创建dir
try {
fs.mkdirSync(Evt.getBasePath() + '/data/');
}
catch(e) {};
try {
fs.mkdirSync(Evt.getBasePath() + '/data/' + this.getCurActiveUserId());
} catch(e) {
}
try {
fs.mkdirSync(Evt.getBasePath() + '/data/' + this.getCurActiveUserId() + '/images');
} catch(e) {
}
try {
fs.mkdirSync(Evt.getBasePath() + '/data/' + this.getCurActiveUserId() + '/attachs');
} catch(e) {
}
},
deleteUserImagesAndAttachsPath: function (userId) {
var me = this;
// 防止误删
if (!Evt.getBasePath()) {
return;
}
var imagesAndAttachBasePath = me.getUserImagesAndAttachBasePath(userId);
if (imagesAndAttachBasePath) {
Common.deleteFolderRecursive(imagesAndAttachBasePath);
}
},
setUserDataPath: function(userId) {
var me = this;
// 判断是否存在, 不存在则创建dir
try {
fs.mkdirSync(Evt.getBasePath() + '/data/');
}
catch(e) {};
try {
fs.mkdirSync(Evt.getBasePath() + '/data/' + this.getCurActiveUserId());
} catch(e) {
}
try {
fs.mkdirSync(Evt.getBasePath() + '/data/' + this.getCurActiveUserId() + '/images');
} catch(e) {
}
try {
fs.mkdirSync(Evt.getBasePath() + '/data/' + this.getCurActiveUserId() + '/attachs');
} catch(e) {
}
},
addImage: function(path, callback) {
var me = this;
var absolutePath = Evt.getBasePath() + '/' + path;
me._addImage(Common.objectId(), absolutePath, callback);
},
addImage: function(path, callback) {
var me = this;
var absolutePath = Evt.getBasePath() + '/' + path;
me._addImage(Common.objectId(), absolutePath, callback);
},
addImage: function(path, callback) {
var me = this;
var absolutePath = Evt.getBasePath() + '/' + path;
me._addImage(Common.objectId(), absolutePath, callback);
},
db.init = function (curUser, dbPath) {
ipc.send('db-init', {
curUser: curUser,
dbPath: dbPath,
dataBasePath: Evt.getBasePath()
});
};