Skip to content

Commit e102b62

Browse files
committed
Store rate limited domains until reset time is over
Uses hard coded 1h 10min. TODO: use header data to determine time. Storing them for a week caused no requests from being made before time elapsed.
1 parent d1cef4b commit e102b62

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

Package Control.sublime-settings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@
139139
"http_cache": true,
140140

141141
// Number of seconds to cache HTTP responses for, defaults to one week
142+
// If a local cache entry hasn't been requested within this time span,
143+
// it will be removed from storage.
142144
"http_cache_length": 604800,
143145

144146
// User agent for HTTP requests. If "%s" is present, will be replaced

package_control/download_manager.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,10 @@ def fetch(self, url, error_message, prefer_cached=False):
499499
return self.downloader.download(url, error_message, timeout, 3, prefer_cached)
500500

501501
except (RateLimitException) as e:
502+
# rate limits are normally reset after an hour
503+
# store rate limited domain for this time to avoid further requests
502504
rate_limited_domains.append(hostname)
503-
set_cache(
504-
'rate_limited_domains',
505-
rate_limited_domains,
506-
self.settings.get('cache_length', 604800)
507-
)
505+
set_cache('rate_limited_domains', rate_limited_domains, 3610)
508506

509507
console_write(
510508
'''

0 commit comments

Comments
 (0)