[conduit/gsoc09_alexandre: 7/24] Changed modules cache location to XDG cache dir.
- From: Alexandre Rosenfeld <arosenfeld src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [conduit/gsoc09_alexandre: 7/24] Changed modules cache location to XDG cache dir.
- Date: Thu, 13 Aug 2009 04:11:48 +0000 (UTC)
commit ec9854f01791f1e2d47c6c1b06995e6b7bbe6823
Author: Alexandre Rosenfeld <airmind gmail com>
Date: Tue Jul 7 03:20:12 2009 -0300
Changed modules cache location to XDG cache dir.
conduit/Module.py | 9 ++-------
conduit/__init__.py | 4 +++-
2 files changed, 5 insertions(+), 8 deletions(-)
---
diff --git a/conduit/Module.py b/conduit/Module.py
index 02c4176..9299087 100644
--- a/conduit/Module.py
+++ b/conduit/Module.py
@@ -63,14 +63,13 @@ class ModuleManager(gobject.GObject):
self.invalidFiles = []
#Keep a ref to dataprovider factories so they are not collected
self.dataproviderFactories = []
- self.cache_path = os.path.join(conduit.USER_DIR, "modules_cache")
+ self.cache_path = os.path.join(conduit.USER_CACHE_DIR, "modules.list")
self.modules_cache = {}
if os.path.exists(self.cache_path):
cache_file = open(self.cache_path, "rb")
try:
- num_modules = 0
- num_files = 0
self.modules_cache = pickle.load(cache_file)
+ #We check all the contents so we dont load an invalid cache
if not isinstance(self.modules_cache, dict):
raise Exception()
for key, value in self.modules_cache.iteritems():
@@ -78,10 +77,6 @@ class ModuleManager(gobject.GObject):
raise Error("%s not a string" % key)
if not isinstance(value, dict):
raise Error("%s not a dict" % value)
- for item in value:
- num_modules += 1
- num_files += 1
- log.critical("Number of files %d, Number of modules %d" % (num_files, num_modules))
except Error:
log.warn("Modules cache invalid")
self.modules_cache = {}
diff --git a/conduit/__init__.py b/conduit/__init__.py
index ed9a4e4..f158a3d 100644
--- a/conduit/__init__.py
+++ b/conduit/__init__.py
@@ -34,9 +34,11 @@ IS_DEVELOPMENT_VERSION = True
#test the existance of some compulsory directories
CONFIG_DIR = os.environ.get("XDG_CONFIG_HOME", os.path.join(os.environ['HOME'], ".config"))
+CACHE_DIR = os.environ.get("XDG_CACHE_HOME", os.path.join(os.environ['HOME'], ".cache"))
AUTOSTART_FILE_DIR = os.path.join(CONFIG_DIR, "autostart")
USER_DIR = os.path.join(CONFIG_DIR, "conduit")
-for d in (AUTOSTART_FILE_DIR, USER_DIR):
+USER_CACHE_DIR = os.path.join(CACHE_DIR, "conduit")
+for d in (AUTOSTART_FILE_DIR, USER_DIR, USER_CACHE_DIR):
if not os.path.exists(d):
os.makedirs(d)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]