diff options
Diffstat (limited to '')
-rw-r--r-- | portato/db/eix_sql.py | 18 | ||||
-rw-r--r-- | portato/db/sql.py | 1 |
2 files changed, 11 insertions, 8 deletions
diff --git a/portato/db/eix_sql.py b/portato/db/eix_sql.py index 0e4f569..ac31019 100644 --- a/portato/db/eix_sql.py +++ b/portato/db/eix_sql.py @@ -21,29 +21,31 @@ import os from .sql import SQLDatabase from ..eix import EixReader -from ..helper import debug +from ..helper import debug, warning from ..backend import system class EixSQLDatabase (SQLDatabase): - CACHE_FILE = "/var/eix/cache" + CACHE_FILE = "/var/cache/eix" def __init__ (self, session): - SQLDatabase.__init__(self, session) - if "cache" not in session: + self.cache = session.get("cache", self.CACHE_FILE) + if not os.path.exists(self.cache): + warning(_("Cache file '%s' does not exist. Using default instead."), self.cache) self.cache = self.CACHE_FILE - session["cache"] = self.cache - else: - self.cache = session["cache"] debug("Using '%s' as eix cache file.", self.cache) + + session["cache"] = self.cache + + SQLDatabase.__init__(self, session) def updated (self): mtime = os.stat(self.cache).st_mtime old = self.session.get("mtime", 0) - self.session["mtime"] = mtime + self.session["mtime"] = str(mtime) return old < mtime diff --git a/portato/db/sql.py b/portato/db/sql.py index 6c95bb3..f2a736e 100644 --- a/portato/db/sql.py +++ b/portato/db/sql.py @@ -256,3 +256,4 @@ class SQLDatabase (Database): self._restrict = "AND (name LIKE '%%%(restrict)s%%' OR cat LIKE '%(restrict)s%%')" % {"restrict":restrict} restrict = property(get_restrict, set_restrict) + con = staticmethod(con) |