fix(edit) set patch only if hashes same

This commit is contained in:
coderaiser 2013-12-02 13:42:49 +00:00
parent 482d6a17e6
commit 63eda23f1a

View file

@ -158,8 +158,6 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch;
Util.ifExec(!isDiff, function(patch) {
var query,
isAllowed = DOM.Storage.isAllowed(),
isString = Util.isString(patch),
lessLength = patch.length < lValue.length,
getSave = function(hash) {
return function(data) {
onSave(data, hash);
@ -167,20 +165,19 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch;
};
Value = lValue;
if (isString && patch.length && lessLength) {
lValue = patch;
query = '?patch';
}
Util.ifExec(!isAllowed, function(loadHash) {
DOM.RESTful.save(lPath, lValue, getSave(loadHash), query);
}, function(callback) {
DOM.checkStorageHash(lPath, function(error, equal, loadHash) {
var isString = Util.isString(patch),
lessLength = patch.length < lValue.length;
if (!error) {
if (!equal)
query = '';
if (equal && isString && patch.length && lessLength) {
lValue = patch;
query = '?patch';
}
callback(loadHash);
}