Don't require HOME to be set and if it set, don't require the directory to
authorJohan Dahlin <johan@async.com.br>
Mon, 8 Dec 2008 20:05:29 +0000 (20:05 +0000)
committerJohan Dahlin <johan@src.gnome.org>
Mon, 8 Dec 2008 20:05:29 +0000 (20:05 +0000)
2008-12-08  Johan Dahlin  <johan@async.com.br>

* giscanner/cachestore.py (_get_cachedir): Don't require
HOME to be set and if it set, don't require the
directory to exist.

svn path=/trunk/; revision=987

ChangeLog
giscanner/cachestore.py

index ba52604..947f80e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2008-12-08  Johan Dahlin  <johan@async.com.br>
 
+       * giscanner/cachestore.py (_get_cachedir): Don't require
+       HOME to be set and if it set, don't require the
+       directory to exist.
+
+2008-12-08  Johan Dahlin  <johan@async.com.br>
+
        * giscanner/cachestore.py (CacheStore.store): Dump the cache
        file to a temporary file and rename it the expected filename
        only when it's completely written.
index b2fee6a..f7f0062 100644 (file)
@@ -26,7 +26,13 @@ import tempfile
 
 
 def _get_cachedir():
-    cachedir = os.path.join(os.environ['HOME'], '.cache')
+    homedir = os.environ.get('HOME')
+    if homedir is None:
+        return None
+    if not os.path.exists(homedir):
+        return None
+
+    cachedir = os.path.join(homedir, '.cache')
     if not os.path.exists(cachedir):
         os.mkdir(cachedir, 0755)