If cache is corrupted than delete it, it will be recreated when needed.
This commit is contained in:
+10
-3
@@ -43,9 +43,16 @@ class LazyDB(Singleton):
|
|||||||
file('/var/cache/pisi/%s.cache' % self.__class__.__name__.lower(), 'wb'), 1)
|
file('/var/cache/pisi/%s.cache' % self.__class__.__name__.lower(), 'wb'), 1)
|
||||||
|
|
||||||
def cache_load(self):
|
def cache_load(self):
|
||||||
if os.path.exists("/var/cache/pisi/%s.cache" % self.__class__.__name__.lower()):
|
cache_file = "/var/cache/pisi/%s.cache" % self.__class__.__name__.lower()
|
||||||
self._instance().__dict__ = cPickle.load(file('/var/cache/pisi/%s.cache' % self.__class__.__name__.lower(), 'rb'))
|
if os.path.exists(cache_file):
|
||||||
return True
|
try:
|
||||||
|
self._instance().__dict__ = cPickle.load(file(cache_file, 'rb'))
|
||||||
|
return True
|
||||||
|
except cPickle.UnpicklingError:
|
||||||
|
# Delete corrupted cache
|
||||||
|
if os.access("/var/cache/pisi", os.W_OK):
|
||||||
|
os.unlink(cache_file)
|
||||||
|
return False
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def cache_flush(self):
|
def cache_flush(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user