gobject-introspection r867 - in trunk: . giscanner
- From: johan svn gnome org
- To: svn-commits-list gnome org
- Subject: gobject-introspection r867 - in trunk: . giscanner
- Date: Fri, 7 Nov 2008 14:09:02 +0000 (UTC)
Author: johan
Date: Fri Nov 7 14:09:02 2008
New Revision: 867
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=867&view=rev
Log:
2008-11-07 Johan Dahlin <jdahlin async com br>
* giscanner/cachestore.py:
Handle broken cache entries, write only filesystems and
running out of diskspace.
Modified:
trunk/ChangeLog
trunk/giscanner/cachestore.py
Modified: trunk/giscanner/cachestore.py
==============================================================================
--- trunk/giscanner/cachestore.py (original)
+++ trunk/giscanner/cachestore.py Fri Nov 7 14:09:02 2008
@@ -61,6 +61,19 @@
return (os.stat(store_filename).st_mtime >=
os.stat(filename).st_mtime)
+ def _purge_cache(self, filename):
+ try:
+ os.unlink(filename)
+ except IOError, e:
+ # Permission denied
+ if e.errno == errno.EACCES:
+ return
+ # File does not exist
+ elif e.errno == errno.ENOENT:
+ return
+ else:
+ raise
+
def store(self, filename, data):
store_filename = self._get_filename(filename)
if store_filename is None:
@@ -69,7 +82,14 @@
self._cache_is_valid(store_filename, filename)):
return None
fd = open(store_filename, 'w')
- cPickle.dump(data, fd)
+ try:
+ cPickle.dump(data, fd)
+ except IOError, e:
+ # No space left on device
+ if e.errno == e.ENOSPC:
+ return
+ else:
+ raise
def load(self, filename):
store_filename = self._get_filename(filename)
@@ -80,8 +100,14 @@
except IOError, e:
if e.errno == errno.ENOENT:
return None
- raise
+ else:
+ raise
if not self._cache_is_valid(store_filename, filename):
return None
- data = cPickle.load(fd)
+ try:
+ data = cPickle.load(fd)
+ except EOFError:
+ # Broken cache entry, remove it
+ self._purge_cache(store_filename)
+ data = None
return data
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]