Skip to content

Commit

Permalink
Try the cache when GitHub ratelimit reached.
Browse files Browse the repository at this point in the history
Related to issue #161.
  • Loading branch information
espadrine committed Jun 10, 2014
1 parent b6ccb95 commit e7a4d93
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var serverSecrets;
try {
// Everything that cannot be checked in but is useful server-side
// is stored in this JSON data.
serverSecrets = require('secret.json');
serverSecrets = require('./secret.json');
} catch(e) {}
var semver = require('semver');
var serverStartTime = new Date((new Date()).toGMTString());
Expand Down Expand Up @@ -893,6 +893,9 @@ cache(function(data, match, sendBadge) {
sendBadge(format, badgeData);
}
try {
if ((+res.headers['x-ratelimit-remaining']) === 0) {
return; // Hope for the best in the cache.
}
var data = JSON.parse(buffer);
var tag = data[0].name;
badgeData.text[1] = tag;
Expand Down

0 comments on commit e7a4d93

Please sign in to comment.