never get new version with timeout -1

This commit is contained in:
j 2008-05-09 19:30:54 +02:00
parent 0a4acbc2f9
commit bf90c228c6

View file

@ -85,13 +85,13 @@ def getUrlCacheFile(url, data=None, headers=DEFAULT_HEADERS):
return os.path.join(getCacheBase(), domain, url_hash[:2], url_hash[2:4], url_hash[4:6], url_hash) return os.path.join(getCacheBase(), domain, url_hash[:2], url_hash[2:4], url_hash[4:6], url_hash)
def loadUrlCache(url_cache_file, timeout=cache_timeout): def loadUrlCache(url_cache_file, timeout=cache_timeout):
if timeout <= 0: if timeout == 0:
return None return None
if os.path.exists(url_cache_file): if os.path.exists(url_cache_file):
ctime = os.stat(url_cache_file).st_ctime ctime = os.stat(url_cache_file).st_ctime
now = time.mktime(time.localtime()) now = time.mktime(time.localtime())
file_age = now-ctime file_age = now-ctime
if file_age < timeout: if timeout < 0 or file_age < timeout:
f = open(url_cache_file) f = open(url_cache_file)
data = f.read() data = f.read()
f.close() f.close()