From: Armin Ronacher Date: Sat, 7 Apr 2007 16:38:00 +0000 (+0200) Subject: [svn] fixed another bug in the same darn file X-Git-Tag: 2.0rc1~368 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=72ae44813e65af42e3c62e2c77716244f7bdda05;p=jinja2.git [svn] fixed another bug in the same darn file --HG-- branch : trunk --- diff --git a/jinja/loaders.py b/jinja/loaders.py index fb904a1..7bd63a8 100644 --- a/jinja/loaders.py +++ b/jinja/loaders.py @@ -191,13 +191,19 @@ class CachedLoaderMixin(object): try: cache_time = path.getmtime(cache_fn) except OSError: - cache_time = -1 - if last_change is None or last_change <= cache_time: - f = file(cache_fn, 'rb') + cache_time = 0 + if last_change is None or (cache_time and + last_change <= cache_time): try: - tmpl = Template.load(environment, f) - finally: - f.close() + f = file(cache_fn, 'rb') + except IOError: + tmpl = None + save_to_disk = True + else: + try: + tmpl = Template.load(environment, f) + finally: + f.close() else: save_to_disk = True