mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
refactor(rest) onFS: rm Util.call
This commit is contained in:
parent
67b4417b75
commit
7ed5337aa2
1 changed files with 15 additions and 23 deletions
|
|
@ -158,32 +158,24 @@
|
|||
});
|
||||
});
|
||||
else if (lQuery === 'patch')
|
||||
getBody(p.request, function(pPatch) {
|
||||
fs.readFile(p.name, Util.call(read, params));
|
||||
getBody(p.request, function(patch) {
|
||||
fs.readFile(p.name, 'utf8', read.bind(null, p.name));
|
||||
|
||||
function read(params) {
|
||||
var lDiff, lStr, p, lData, lName,
|
||||
ret = main.checkCallBackParams(params) &&
|
||||
main.checkParams(params.params);
|
||||
|
||||
if (ret) {
|
||||
p = params;
|
||||
lName = p.params.name;
|
||||
function read(name, error, data) {
|
||||
checkSendError(error, params, function() {
|
||||
var diffResult;
|
||||
|
||||
checkSendError(p.error, p.params, function() {
|
||||
lStr = p.data.toString();
|
||||
ret = Util.tryCatchLog(function() {
|
||||
lDiff = diff.applyPatch(lStr, pPatch);
|
||||
});
|
||||
|
||||
if (lDiff && !ret)
|
||||
fs.writeFile(lName, lDiff, Util.call(write, p.params));
|
||||
else {
|
||||
lName = path.basename(lName);
|
||||
sendMsg(p.params, 'patch', lName, 'fail');
|
||||
}
|
||||
ret = Util.tryCatchLog(function() {
|
||||
diffResult = diff.applyPatch(data, patch);
|
||||
});
|
||||
}
|
||||
|
||||
if (diffResult && !ret)
|
||||
fs.writeFile(name, diffResult, Util.call(write, params));
|
||||
else {
|
||||
name = path.basename(name);
|
||||
sendMsg(params, 'patch', name, 'fail');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function write(params) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue