Recover from corrupted roster cache

pull/1/head
yflory 4 years ago
parent d7b4fca703
commit 7b1a4b1ae7

@ -573,6 +573,14 @@ var factory = function (Util, Hash, CPNetflux, Sortify, nThen, Crypto, Feedback)
var ready = false;
var onCacheReady = function () {
if (!config.onCacheReady) { return; }
var state = ref.state;
if (!Object.keys(state.members || {}).length) {
// No member, corrupted cache
try {
ref.internal.cpNetflux.resetCache();
} catch (e) { console.error(e); }
return void config.onCacheReady({error: "CORRUPTED"});
}
config.onCacheReady(roster);
};
var onReady = function (info) {

@ -547,6 +547,14 @@ define([
store: ctx.store,
lastKnownHash: rosterData.lastKnownHash,
onCacheReady: function (_roster) {
if (!cache) { return; }
console.error('Corrupted roster cache, cant load this team offline', teamData);
if (_roster && _roster.error === "CORRUPTED") {
if (lm && typeof(lm.stop) === "function") { lm.stop(); }
waitFor.abort();
cb({error: 'CACHE_CORRUPTED_ROSTER'});
return;
}
roster = _roster;
cacheRdy.roster = true;
cacheRdy.check();

Loading…
Cancel
Save