Fix: missing id when updating digest

This commit is contained in:
eight 2017-10-04 16:19:20 +08:00
parent c2eadda708
commit 2912a53729

View File

@ -127,19 +127,20 @@ var updater = {
if (!styleJSONseemsValid(json)) { if (!styleJSONseemsValid(json)) {
return Promise.reject(updater.ERROR_JSON); return Promise.reject(updater.ERROR_JSON);
} }
if (styleSectionsEqual(json, style)) {
// JSONs may have different order of items even if sections are effectively equal
// so we'll update the digest anyway
saveStyle(Object.assign(json, {reason: 'update-digest'}));
return Promise.reject(updater.SAME_CODE);
} else if (!style.originalDigest && !ignoreDigest) {
return Promise.reject(updater.MAYBE_EDITED);
}
return json; return json;
} }
function maybeSave(json) { function maybeSave(json) {
json.id = style.id; json.id = style.id;
if (styleSectionsEqual(json, style)) {
// JSONs may have different order of items even if sections are effectively equal
// so we'll update the digest anyway
// always update digest even if (save === false)
saveStyle(Object.assign(json, {reason: 'update-digest'}));
return Promise.reject(updater.SAME_CODE);
} else if (!style.originalDigest && !ignoreDigest) {
return Promise.reject(updater.MAYBE_EDITED);
}
if (!save) { if (!save) {
return json; return json;
} }