Skip to content

Commit 34f02ad

Browse files
committedMay 19, 2015
Report already checked but broken remote links on all pages
1 parent cb316c3 commit 34f02ad

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎nikola/plugins/command/check.py

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

175175
existing_targets = set([])
176-
checked_remote_targets = []
176+
checked_remote_targets = {}
177177

178178
def analyze(self, task, find_sources=False, check_remote=False):
179179
rv = False
@@ -219,13 +219,13 @@ def analyze(self, task, find_sources=False, check_remote=False):
219219
if parsed.netloc == base_url.netloc: # absolute URL to self.site
220220
continue
221221
if target in self.checked_remote_targets: # already checked this exact target
222+
if self.checked_remote_targets[target] > 399:
223+
self.logger.warn("Broken link in {0}: {1} [Error {2}]".format(filename, target, self.checked_remote_targets[target]))
222224
continue
223-
self.checked_remote_targets.append(target)
224-
225225
# Check the remote link works
226226
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!
227227
resp = requests.head(target, headers=req_headers)
228-
228+
self.checked_remote_targets[target] = resp.status_code
229229
if resp.status_code > 399: # Error
230230
self.logger.warn("Broken link in {0}: {1} [Error {2}]".format(filename, target, resp.status_code))
231231
continue

0 commit comments

Comments
 (0)
Please sign in to comment.