~ chicken-core (chicken-5) 1d86781b3c9c02c6f0bc0752516642f9d93a5ae3


commit 1d86781b3c9c02c6f0bc0752516642f9d93a5ae3
Author:     Evan Hanson <evhan@foldling.org>
AuthorDate: Wed Jan 3 17:58:00 2018 +1300
Commit:     felix <felix@call-with-current-continuation.org>
CommitDate: Thu Jan 4 12:11:40 2018 +0100

    Minor changes to egg cache dir handling
    
     - Avoid error on "chicken-install -purge" when cache dir doesn't exist.
     - Don't cache builds in "/tmp" or "/Temp".
     - Use ".chicken-install/cache" path for egg cache.
     - Create cache dir recursively (i.e. "mkdir -p") in case parent
       directories don't exist.
     - Drop unnecessary call to `file-exists?' in `probe-dir' (testing the
       path with `directory?' is enough).
     - Drop redundant call to `create-directory' in `fetch-egg' (the cache
       dir is already created in the `fetch' helper procedure).
    
    Signed-off-by: felix <felix@call-with-current-continuation.org>

diff --git a/chicken-install.scm b/chicken-install.scm
index 7e4e86cd..bfefdb30 100644
--- a/chicken-install.scm
+++ b/chicken-install.scm
@@ -112,16 +112,14 @@
         (get-environment-variable "DYLD_LIBRARY_PATH")))
 
 (define (probe-dir dir)
-  (and dir (file-exists? dir) (directory? dir) dir))
-  
+  (and dir (directory? dir) dir))
+
 (define cache-directory
   (or (get-environment-variable "CHICKEN_EGG_CACHE")
       (make-pathname (or (probe-dir (get-environment-variable "HOME"))
                          (probe-dir (get-environment-variable "USERPROFILE"))
-                         (probe-dir "/tmp")
-                         (probe-dir "/Temp")
-                         ".")
-                     ".chicken-install.cache")))
+                         (current-directory))
+                     ".chicken-install/cache")))
 
 (define (repo-path)
   (if (and cross-chicken (not host-extension))
@@ -410,11 +408,9 @@
     (define (fetch lax)
       (when (file-exists? cached)
         (delete-directory cached #t))
-      (create-directory cached)
+      (create-directory cached #t)
       (fetch-egg-sources name version cached lax)
       (with-output-to-file status (cut write current-status)))
-    (unless (file-exists? cache-directory)
-      (create-directory cache-directory))
     (cond ((or (not (probe-dir cached))
                (not (file-exists? eggfile)))
            (d "~a not cached~%" name)
@@ -964,8 +960,9 @@
 
 (define (purge-cache eggs)
   (cond ((null? eggs)
-         (d "purging complete cache at ~a~%" cache-directory)
-         (delete-directory cache-directory #t))
+         (when (file-exists? cache-directory)
+           (d "purging complete cache at ~a~%" cache-directory)
+           (delete-directory cache-directory #t)))
         (else
           (for-each
             (lambda (egg)
Trap