diff --git a/lib/server/hash.js b/lib/server/hash.js index 011c59fe..a4f88c5c 100644 --- a/lib/server/hash.js +++ b/lib/server/hash.js @@ -6,7 +6,7 @@ util.inherits(HashProto, Writable); - object.Hash = new HashProto(); + object.create = new HashProto().create; function HashProto() { var shasum, diff --git a/lib/server/main.js b/lib/server/main.js index 0edf8d0f..b6b51ec9 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -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, diff --git a/lib/server/rest.js b/lib/server/rest.js index 176110bd..c3822079 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -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() {