add ignore_missing flag and do not cache already-cached aliases

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2490 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2005-03-29 20:26:35 +00:00
parent d4f40ca18e
commit 5b64583904
2 changed files with 12 additions and 10 deletions

View file

@ -168,15 +168,18 @@ class Cache (linkcheck.lock.AssertLock):
finally:
self.release()
def in_progress_remove (self, url_data):
def in_progress_remove (self, url_data, ignore_missing=False):
"""
Remove url from in-progress cache.
Remove url from in-progress cache. If url is not cached and
ignore_missing evaluates True, raise AssertionError.
"""
self.acquire()
try:
key = url_data.cache_url_key
assert key in self.in_progress, key
del self.in_progress[key]
if key in self.in_progress:
del self.in_progress[key]
else:
assert ignore_missing, repr(key)
finally:
self.release()
@ -197,11 +200,10 @@ class Cache (linkcheck.lock.AssertLock):
self.checked[key] = data
# add all aliases also to checked cache to avoid recursion
for key in url_data.aliases:
linkcheck.log.debug(linkcheck.LOG_CACHE,
"Cache alias %r...", key)
assert key not in self.checked, \
key + u", " + unicode(self.checked[key])
self.checked[key] = data
if key not in self.checked:
linkcheck.log.debug(linkcheck.LOG_CACHE,
"Cache alias %r...", key)
self.checked[key] = data
finally:
self.release()

View file

@ -112,7 +112,7 @@ class Consumer (linkcheck.lock.AssertLock):
"""
Remove url from active list.
"""
self.cache.in_progress_remove(url_data)
self.cache.in_progress_remove(url_data, ignore_missing=True)
def finished (self):
"""