changeset 104292:3a381ae2eb0e

* files.el (get-free-disk-space): Change fallback default directory to /. Expand DIR argument before switching to fallback. Suggested by Kevin Ryde (Bug#2631, Bug#3911).
author Chong Yidong <cyd@stupidchicken.com>
date Sun, 16 Aug 2009 00:31:28 +0000
parents a43e99d78f43
children 012ded1c9caf
files lisp/ChangeLog lisp/files.el
diffstat 2 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat Aug 15 22:02:59 2009 +0000
+++ b/lisp/ChangeLog	Sun Aug 16 00:31:28 2009 +0000
@@ -1,3 +1,9 @@
+2009-08-16  Chong Yidong  <cyd@stupidchicken.com>
+
+	* files.el (get-free-disk-space): Change fallback default
+	directory to /.  Expand DIR argument before switching to fallback.
+	Suggested by Kevin Ryde (Bug#2631, Bug#3911).
+
 2009-08-15  Chong Yidong  <cyd@stupidchicken.com>
 
 	* files.el (load-library): Doc fix.
--- a/lisp/files.el	Sat Aug 15 22:02:59 2009 +0000
+++ b/lisp/files.el	Sun Aug 16 00:31:28 2009 +0000
@@ -5386,7 +5386,7 @@
 
 This function calls `file-system-info' if it is available, or invokes the
 program specified by `directory-free-space-program' if that is non-nil."
-  (when (not (file-remote-p dir))
+  (unless (file-remote-p dir)
     ;; Try to find the number of free blocks.  Non-Posix systems don't
     ;; always have df, but might have an equivalent system call.
     (if (fboundp 'file-system-info)
@@ -5396,12 +5396,14 @@
       (save-match-data
 	(with-temp-buffer
 	  (when (and directory-free-space-program
-		     (let ((default-directory
-			     (if (and (not (file-remote-p default-directory))
-				      (file-directory-p default-directory)
-				      (file-readable-p default-directory))
-				 default-directory
-			       (expand-file-name "~/"))))
+		     ;; Avoid failure if the default directory does
+		     ;; not exist (Bug#2631, Bug#3911).
+		     (let ((default-directory default-directory))
+		       (setq dir (expand-file-name dir))
+		       (unless (and (not (file-remote-p default-directory))
+				    (file-directory-p default-directory)
+				    (file-readable-p default-directory))
+			 (setq default-directory "/"))
 		       (eq (call-process directory-free-space-program
 					 nil t nil
 					 directory-free-space-args