feature(hash) add handling old node versions

This commit is contained in:
coderaiser 2013-11-19 08:58:30 +00:00
parent ece4742e9b
commit 62546f1eae
3 changed files with 20 additions and 14 deletions

View file

@ -6,7 +6,7 @@
util.inherits(HashProto, Writable);
object.Hash = new HashProto();
object.create = new HashProto().create;
function HashProto() {
var shasum,

View file

@ -108,7 +108,7 @@
exports.auth = srvrequire('auth').auth,
exports.appcache = srvrequire('appcache'),
exports.dir = srvrequire('dir'),
exports.hash = srvrequire('hash').Hash;
exports.hash = srvrequire('hash'),
diffPatch = librequire('diff/diff-match-patch').diff_match_patch,
exports.diff = new (librequire('diff').DiffProto)(diffPatch),
exports.rest = srvrequire('rest').api,

View file

@ -117,18 +117,24 @@
});
});
else if (Util.strCmp(lQuery, 'hash')) {
hash = Hash.create();
pipe.create({
from : p.name,
write : hash,
callback : function (error) {
checkSendError(error, p, function() {
var hex = hash.get();
sendResponse(p, hex);
});
}
});
if (!Hash) {
lMsg = 'not suported, try update node';
lMsg = CloudFunc.formatMsg('hash', lMsg, 'error');
sendError(p, lMsg);
} else {
hash = Hash.create();
pipe.create({
from : p.name,
write : hash,
callback : function (error) {
checkSendError(error, p, function() {
var hex = hash.get();
sendResponse(p, hex);
});
}
});
}
} else
fs.stat(p.name, function(pError, pStat) {
checkSendError(pError, p, function() {