This commit is contained in:
life
2015-04-06 18:22:55 +08:00
parent 4c8bd52b6c
commit b0601eeb53
4 changed files with 39 additions and 17 deletions

24
src/node_modules/common.js generated vendored
View File

@@ -164,18 +164,28 @@ var Common = {
// 执行命令
cmd: function(args, exitFunc) {
var me = this;
var exec = require('child_process').exec;
var binPath = process.cwd() + '/public/bin/leanote-mac';
if(me.isWin()) {
var binPath = process.cwd() + '/public/bin/leanote.exe';
}
var exec = require('child_process').exec;
var cmd = '"' + binPath + '"'; // "' + txtPath + '" "' + filePath + '"'
for(var i in args) {
cmd += ' "' + args[i] + '"';
go();
} else {
// 先chmod +x
var chmod = exec('chmod +x "' + binPath + '"');
chmod.on('exit', function(code) {
go();
});
}
last = exec(cmd);
last.on('exit', exitFunc);
function go() {
var cmd = '"' + binPath + '"'; // "' + txtPath + '" "' + filePath + '"'
for(var i in args) {
cmd += ' "' + args[i] + '"';
}
last = exec(cmd);
last.on('exit', exitFunc);
}
}
};
module.exports = Common;

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

@@ -91,13 +91,17 @@ var File = {
console.log('子进程已关闭,代码:' + code);
fs.unlink(txtPath);
if(!code) {
if(isImage) {
me._addImage(Common.objectId(), filePath, function(newImg) {
newImg.IsImage = true;
callback && callback(newImg);
});
} else {
me._addAttach(filePath, fileTitle, callback)
try {
if(isImage) {
me._addImage(Common.objectId(), filePath, function(newImg) {
newImg.IsImage = true;
callback && callback(newImg);
});
} else {
me._addAttach(filePath, fileTitle, callback)
}
} catch(e) {
callback(false);
}
} else {
callback(false);
@@ -112,7 +116,12 @@ var File = {
}
},
_addAttach: function(filePath, fileTitle, callback) {
var fileStat = fs.statSync(filePath);
try {
var fileStat = fs.statSync(filePath);
} catch(e) {
callback(false);
return;
}
var paths = filePath.split(Common.getPathSep()); // windows的filePath不同
var name = paths[paths.length-1];
// Web.alertWeb(name);

5
src/node_modules/import.js generated vendored
View File

@@ -111,7 +111,10 @@ var Import = {
var mime = res['mime'][0].toLowerCase();
if(mime.indexOf('image') == 0) {
isImage = true;
type = mime.split('/').pop();
}
type = mime.split('/').pop();
if(type == '') {
type = 'raw';
}
// console.log(base64Str);