[svn] fixed another bug in the same darn file
authorArmin Ronacher <armin.ronacher@active-4.com>
Sat, 7 Apr 2007 16:38:00 +0000 (18:38 +0200)
committerArmin Ronacher <armin.ronacher@active-4.com>
Sat, 7 Apr 2007 16:38:00 +0000 (18:38 +0200)
--HG--
branch : trunk

jinja/loaders.py

index fb904a1ff8077dca280f1cf2f0e08d831d2faeca..7bd63a85a2a747288a2d62df49709c260f56a351 100644 (file)
@@ -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