diff --git a/lib/client/dom.js b/lib/client/dom.js index d030c520..b5604638 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1486,6 +1486,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; lName += lExt; } + DOM.saveDataToCache(lName, pData); + Util.exec(pCallBack, { data: pData, name: lName @@ -1758,25 +1760,26 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; */ this.saveDataToCache = function(name, data, callback) { CloudCmd.getConfig(function(config) { - var cacheName, - allowed = config.localStorage; + var hash, + nameHash = name + '-hash', + nameData = name + '-data', + allowed = config.localStorage; if (!allowed) Util.exec(callback); else { - cacheName = name + '-data'; + hash = Cache.get(name + '-hash'); - if (!!Cache.get(cacheName)) { - Cache.set(cacheName, data); - DOM.loadCurrentHash(function(hash) { - var isContain = Util.isContainStr(hash, 'error'); - - if (!isContain) - Cache.set(name + '-hash', hash); - - Util.exec(callback, hash); - }); - } + DOM.loadCurrentHash(function(pHash) { + var isContain = Util.isContainStr(hash, 'error'); + + if (!isContain && hash !== pHash) { + Cache.set(nameHash, pHash); + Cache.set(nameData, data); + } + + Util.exec(callback, hash); + }); } }); };