diff --git a/node_modules/common.js b/node_modules/common.js index 69716b5c..8cb5eba2 100644 --- a/node_modules/common.js +++ b/node_modules/common.js @@ -276,13 +276,14 @@ var Common = { // 删除文件夹 deleteFolderRecursive: function(path) { + var me = this; var files = []; if( fs.existsSync(path) ) { files = fs.readdirSync(path); files.forEach(function(file,index){ var curPath = path + "/" + file; if(fs.statSync(curPath).isDirectory()) { // recurse - deleteFolderRecursive(curPath); + me.deleteFolderRecursive(curPath); } else { // delete file fs.unlinkSync(curPath); } diff --git a/node_modules/user.js b/node_modules/user.js index b5938869..adc90143 100644 --- a/node_modules/user.js +++ b/node_modules/user.js @@ -251,11 +251,14 @@ User = { return 'data/' + this.getCurActiveUserId() + '/attachs'; }, + getUserImagesAndAttachBasePath: function(userId) { + return Evt.getBasePath() + '/data/' + userId; + }, getUserImagesPath: function(userId) { - return Evt.getBasePath() + '/data/' + userId + '/images'; + return this.getUserImagesAndAttachBasePath() + '/images'; }, getUserAttachsPath: function(userId) { - return Evt.getBasePath() + '/data/' + userId + '/attachs'; + return this.getUserImagesAndAttachBasePath() + '/attachs'; }, getUserDBPath: function (userId) { @@ -275,13 +278,9 @@ User = { return; } - var imagesPath = me.getUserImagesPath(userId); - var attachsPath = me.getUserAttachsPath(userId); - if (imagesPath) { - Common.deleteFolderRecursive(imagesPath); - } - if (attachsPath) { - Common.deleteFolderRecursive(attachsPath); + var imagesAndAttachBasePath = me.getUserImagesAndAttachBasePath(userId); + if (imagesAndAttachBasePath) { + Common.deleteFolderRecursive(imagesAndAttachBasePath); } }, diff --git a/public/plugins/accounts/plugin.js b/public/plugins/accounts/plugin.js index c6e03752..64bd9a87 100644 --- a/public/plugins/accounts/plugin.js +++ b/public/plugins/accounts/plugin.js @@ -366,7 +366,7 @@ define(function() { return callback(); } async.eachSeries(notes, function (note, cb) { - Api.dbService.noteHistories.remove( {_id: note.NoteId}, { multi: true }, function () { + sourceDb.noteHistories.remove( {_id: note.NoteId}, { multi: true }, function () { cb(); }); }, function () {