本地用户优化, 无博客, 不能导出pdf

新建用户默认添加笔记本, 笔记, 标签
This commit is contained in:
life
2015-09-24 00:44:16 +08:00
parent 6c89ef2fc8
commit 9a9bdad038
17 changed files with 220 additions and 155 deletions

20
src/node_modules/file.js generated vendored
View File

@@ -159,7 +159,7 @@ var File = {
IsDirty: true, // 本地是新添加的, ServerFileId = 0
CreatedTime: new Date()
};
Attachs.insert(attach);
db.attachs.insert(attach);
callback && callback(attach);
},
@@ -291,7 +291,7 @@ var File = {
if(isForce) {
image.ServerFileId = fileId;
}
Images.insert(image, function(err, doc) {
db.images.insert(image, function(err, doc) {
log(err);
if(err) {
callback && callback(false);
@@ -306,7 +306,7 @@ var File = {
addImageForce: function(fileId, path, callback) {
var me = this;
// 先删除之, 可能是本地有记录, 但是文件没了
Images.remove({FileId: fileId}, function() {
db.images.remove({FileId: fileId}, function() {
me._addImage(fileId, path, callback, true);
});
},
@@ -316,8 +316,8 @@ var File = {
// 因为图片的链接 有可能是本地添加的, 又有可能是远程的
// 如果是远程的, FileId == ServerFileId, 是一样的, 所以不要Or
getImageLocalPath: function(fileId, callback) {
// Images.findOne({$or: {FileId: fileId}, {ServerFileId: fileId}}, function(err, doc) {
Images.findOne({FileId: fileId}, function(err, doc) {
// db.images.findOne({$or: {FileId: fileId}, {ServerFileId: fileId}}, function(err, doc) {
db.images.findOne({FileId: fileId}, function(err, doc) {
if(!err && doc && doc.Path) { // FileLocalPath是相对于项目的路径
callback(true, doc.Path);
} else {
@@ -329,7 +329,7 @@ var File = {
// 得到fileIds所有的images, 为了发送到服务器上
getAllImages: function(fileIds, callback) {
var me = this;
Images.find({$or:[{FileId: {$in: fileIds}}, {ServerFileId: {$in: fileIds}}]}, function(err, images) {
db.images.find({$or:[{FileId: {$in: fileIds}}, {ServerFileId: {$in: fileIds}}]}, function(err, images) {
if(err || !images) {
return callback(false);
}
@@ -352,7 +352,7 @@ var File = {
if(!file.FileId || !file.LocalFileId) {
continue;
}
Images.update({FileId: file.LocalFileId}, {$set: {ServerFileId: file.FileId, IsDirty: false}});
db.images.update({FileId: file.LocalFileId}, {$set: {ServerFileId: file.FileId, IsDirty: false}});
}
},
@@ -503,7 +503,7 @@ var File = {
IsDirty: true, // 本地是新添加的, ServerFileId = 0
CreatedTime: new Date()
};
Attachs.insert(attach);
db.attachs.insert(attach);
targets.push(attach);
}
@@ -513,7 +513,7 @@ var File = {
deleteNotExistsAttach: function(noteId, attachs) {
var me = this;
// console.log('--');
Attachs.find({NoteId: noteId}, function(err, everAttachs) {
db.attachs.find({NoteId: noteId}, function(err, everAttachs) {
if(err) {
return;
}
@@ -525,7 +525,7 @@ var File = {
for(var i in everAttachs) {
var attach = everAttachs[i];
if(!nowMap[attach.FileId]) { // 如果不在, 则删除之
Attachs.remove({FileId: attach.FileId});
db.attachs.remove({FileId: attach.FileId});
// 删除源文件, 别删错了啊
if(attach.Path.indexOf(fileBasePath) >= 0) {
fs.unlink(attach.Path);