Skip to content

Commit cb316c3

Browse files
committedMay 19, 2015
Don’t recheck the same remote address more than once
Fixe #1732
1 parent 7553b5a commit cb316c3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
 

‎CHANGES.txt

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Features
1010
Bugfixes
1111
--------
1212

13+
* Don’t check the same remote URL more than once (Issue #1732)
1314
* All remotely checked links resulted in incorrect warnings (`nikola check -lr`)
1415
* Exclude `<meta content="noindex" name="robots">` from sitemaps
1516
* new_post paths are now relative to CWD (Issue #1325)

‎nikola/plugins/command/check.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ def _execute(self, options, args):
173173
sys.exit(1)
174174

175175
existing_targets = set([])
176+
checked_remote_targets = []
Has conversations. Original line has conversations.
176177

177178
def analyze(self, task, find_sources=False, check_remote=False):
178179
rv = False
@@ -215,11 +216,16 @@ def analyze(self, task, find_sources=False, check_remote=False):
215216
((parsed.scheme or target.startswith('//')) and url_type in ('rel_path', 'full_path')):
216217
if not check_remote or parsed.scheme not in ["http", "https"]:
217218
continue
218-
if parsed.netloc == base_url.netloc:
219+
if parsed.netloc == base_url.netloc: # absolute URL to self.site
219220
continue
221+
if target in self.checked_remote_targets: # already checked this exact target
222+
continue
223+
self.checked_remote_targets.append(target)
224+
220225
# Check the remote link works
221226
req_headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0 (Nikola)'} # I’m a real boy!
Has conversations. Original line has conversations.
222227
resp = requests.head(target, headers=req_headers)
228+
223229
if resp.status_code > 399: # Error
224230
self.logger.warn("Broken link in {0}: {1} [Error {2}]".format(filename, target, resp.status_code))
225231
continue

0 commit comments

Comments
 (0)
Please sign in to comment.