summaryrefslogtreecommitdiff
path: root/giscanner/cachestore.py
diff options
context:
space:
mode:
Diffstat (limited to 'giscanner/cachestore.py')
-rw-r--r--giscanner/cachestore.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/giscanner/cachestore.py b/giscanner/cachestore.py
index e3b76058..3512badc 100644
--- a/giscanner/cachestore.py
+++ b/giscanner/cachestore.py
@@ -169,12 +169,14 @@ class CacheStore(object):
return None
else:
raise
- if not self._cache_is_valid(store_filename, filename):
- return None
- try:
- data = pickle.load(fd)
- except Exception:
- # Broken cache entry, remove it
- self._remove_filename(store_filename)
- data = None
- return data
+
+ with fd:
+ if not self._cache_is_valid(store_filename, filename):
+ return None
+ try:
+ data = pickle.load(fd)
+ except Exception:
+ # Broken cache entry, remove it
+ self._remove_filename(store_filename)
+ data = None
+ return data