From 3b92b00d877b216aca91f30abc28fd2bab6da7ab Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Tue, 26 Oct 2010 22:33:28 -0400 Subject: [PATCH] Cache should check for success of func() We return after checking if the fetcher function succeeds. To do this properly, we should store the value we get so that the cached file can be closed before returning. --- libsaria/cache.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libsaria/cache.py b/libsaria/cache.py index dcf2ad49..19db5329 100644 --- a/libsaria/cache.py +++ b/libsaria/cache.py @@ -19,12 +19,13 @@ class CacheObject: path = join(self.path, key) if not exists(path): f = open(path, 'w') - if func(f, *args): - return path + success = func(f, *args) try: f.close() except: pass + if success: + return path else: return path