changeset 1103:ecaf2b70cd45

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Sat, 12 Sep 1992 08:44:18 +0000
parents ff73961932eb
children f3a7122a68e1
files lisp/files.el
diffstat 1 files changed, 19 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/files.el	Sat Sep 12 07:46:41 1992 +0000
+++ b/lisp/files.el	Sat Sep 12 08:44:18 1992 +0000
@@ -787,11 +787,16 @@
 			       (let ((attr (file-attributes real-file-name)))
 				 (or (nth 9 attr)
 				     (/= (nth 2 attr) (user-uid))))))
-		      (copy-file real-file-name backupname t t)
-; rename-file should delete old backup.
-;		    (condition-case ()
-;			(delete-file backupname)
-;		      (file-error nil))
+		      (condition-case ()
+			  (copy-file real-file-name backupname t t)
+			(file-error
+			 ;; If copying fails because file BACKUPNAME
+			 ;; is not writable, delete that file and try again.
+			 (if (and (file-exists-p backupname)
+				  (not (file-writable-p backupname)))
+			     (delete-file backupname))
+			 (copy-file real-file-name backupname t t)))
+		    ;; rename-file should delete old backup.
 		    (rename-file real-file-name backupname t)
 		    (setq setmodes (file-modes backupname)))
 		(file-error
@@ -799,7 +804,15 @@
 		 (setq backupname (expand-file-name "~/%backup%~"))
 		 (message "Cannot write backup file; backing up in ~/%%backup%%~")
 		 (sleep-for 1)
-		 (copy-file real-file-name backupname t t)))
+		 (condition-case ()
+		     (copy-file real-file-name backupname t t)
+		   (file-error
+		    ;; If copying fails because file BACKUPNAME
+		    ;; is not writable, delete that file and try again.
+		    (if (and (file-exists-p backupname)
+			     (not (file-writable-p backupname)))
+			(delete-file backupname))
+		    (copy-file real-file-name backupname t t)))))
 	      (setq buffer-backed-up t)
 	      ;; Now delete the old versions, if desired.
 	      (if delete-old-versions