From 11bbf066b1a0e9d3988553a5cc0df43ad2458ba1 Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Wed, 6 May 2009 11:57:36 +0000 Subject: [PATCH] Use right path for cache files when -D is used with any operation --- pisi/db/lazydb.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pisi/db/lazydb.py b/pisi/db/lazydb.py index f0d7724e..1995ca5f 100644 --- a/pisi/db/lazydb.py +++ b/pisi/db/lazydb.py @@ -14,6 +14,7 @@ import os import cPickle import time import pisi.context as ctx +import pisi.util as util import string # lower borks for international locales. What we want is ascii lower. @@ -42,10 +43,10 @@ class LazyDB(Singleton): return self.initialized def __cache_file(self): - return "/var/cache/pisi/%s.cache" % self.__class__.__name__.translate(lower_map) + return util.join_path(ctx.config.cache_root_dir(), "%s.cache" % self.__class__.__name__.translate(lower_map)) def cache_save(self): - if os.access("/var/cache/pisi", os.W_OK) and self.cacheable: + if os.access(ctx.config.cache_root_dir(), os.W_OK) and self.cacheable: cPickle.dump(self._instance().__dict__, file(self.__cache_file(), 'wb'), 1) @@ -55,7 +56,7 @@ class LazyDB(Singleton): self._instance().__dict__ = cPickle.load(file(self.__cache_file(), 'rb')) return True except (cPickle.UnpicklingError, EOFError): - if os.access("/var/cache/pisi", os.W_OK): + if os.access(ctx.config.cache_root_dir(), os.W_OK): os.unlink(self.__cache_file()) return False return False