changeset 5050:84478801c884

merged moin/1.8
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 29 Aug 2009 16:25:24 +0200
parents 7a2151bf2797 (current diff) 708fc89b4ebc (diff)
children 40e3e50d4b47
files
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/caching.py	Fri Aug 28 13:37:03 2009 +0200
+++ b/MoinMoin/caching.py	Sat Aug 29 16:25:24 2009 +0200
@@ -168,21 +168,28 @@
         if not self.locking or self.locking and self._lock.acquire(1.0):
             try:
                 if 'r' in mode:
-                    self._fileobj = open(self._fname, mode, bufsize)
+                    filename = self._fname
+                    self._fileobj = open(filename, mode, bufsize)
                 elif 'w' in mode:
                     # we do not write content to old inode, but to a new file
                     # so we don't need to lock when we just want to read the file
                     # (at least on POSIX, this works)
-                    fd, self._tmp_fname = tempfile.mkstemp('.tmp', self.key, self.arena_dir)
+                    filename = None
+                    fd, filename = tempfile.mkstemp('.tmp', self.key, self.arena_dir)
+                    self._tmp_fname = filename
                     self._fileobj = os.fdopen(fd, mode, bufsize)
                 else:
                     raise ValueError("caching: mode does not contain 'r' or 'w'")
-            finally:
+            except IOError, err:
                 if self.locking:
                     self._lock.release()
                     self._lock = None
+                logging.error("Can't open cache file %s [%s]" % (filename, str(err)))
+                raise CacheError(str(err))
         else:
-            logging.error("Can't acquire read/write lock in %s" % self.lock_dir)
+            err = "Can't acquire read/write lock in %s" % self.lock_dir
+            logging.error(err)
+            raise CacheError(err)
 
 
     def read(self, size=-1):