Skip to content

Commit

Permalink
moved failed into env
Browse files Browse the repository at this point in the history
  • Loading branch information
yofreke committed Jul 20, 2015
1 parent 59ba626 commit 3aa8ff0
Showing 1 changed file with 48 additions and 4 deletions.
52 changes: 48 additions & 4 deletions packages/jsio.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,17 @@
}
}
};

var _failedFetches = {};

this.hasFetchFailed = function(path) {
return (path in _failedFetches);
};

this.setFetchFailed = function(path) {
_failedFetches[path] = true;
};

}

function ENV_browser() {
Expand Down Expand Up @@ -614,9 +625,42 @@

return xhr.responseText;
};
};

var failedFetch = {};
var _namespace = null;

this._getNamespace = function() {
if (!_namespace) {
var cwd = this.getCwd();
var _namespace = cwd.substring(cwd.indexOf('apps/'), cwd.length);
if (_namespace.charAt(_namespace.length - 1) === '/') { _namespace = _namespace.substring(0, _namespace.length - 1); }
_namespace += ':';
}
return _namespace;
}

var oldFailedKey = this._getNamespace() + 'failedFetches';

This comment has been minimized.

Copy link
@mgh

mgh Jul 29, 2015

Contributor

what is namespace? it should not be looking for apps/ in the cwd

var _failedFetches = null;

this.hasFetchFailed = function(path) {
if (!_failedFetches) {
var oldFailed = localStorage.getItem(oldFailedKey);
if (oldFailed) {
_failedFetches = JSON.parse(oldFailed);
} else {
_failedFetches = {};
}
}

return (path in _failedFetches);
};

this.setFetchFailed = function(path) {
_failedFetches[path] = true;
// Save it
localStorage.setItem(oldFailedKey, JSON.stringify(_failedFetches));
};

};

function findModule(possibilities) {
var src;
Expand Down Expand Up @@ -648,7 +692,7 @@
possible.src = src;
return possible;
} else {
failedFetch[path] = true;
ENV.setFetchFailed(path);
}
}

Expand Down Expand Up @@ -677,7 +721,7 @@
return possibilities[i];
}

if (path in failedFetch) { possibilities.splice(i--, 1); }
if (ENV.hasFetchFailed(path)) { possibilities.splice(i--, 1); }
}

if (!possibilities.length) {
Expand Down

0 comments on commit 3aa8ff0

Please sign in to comment.