From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.bugs Subject: Re: backup-buffer-copy loops if old backup can't be deleted Date: Tue, 21 Aug 2007 15:35:28 -0400 Message-ID: References: <46CAD810.3050904@gmx.net> <46CAF8AC.9070809@gmx.at> <46CAFBEF.2040606@gmx.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1187724686 28866 80.91.229.12 (21 Aug 2007 19:31:26 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 21 Aug 2007 19:31:26 +0000 (UTC) Cc: Martin von Gagern To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 21 21:31:25 2007 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1INZRi-0001EX-GZ for geb-bug-gnu-emacs@m.gmane.org; Tue, 21 Aug 2007 21:31:22 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1INZRi-00011J-4R for geb-bug-gnu-emacs@m.gmane.org; Tue, 21 Aug 2007 15:31:22 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1INZRg-00011D-ND for bug-gnu-emacs@gnu.org; Tue, 21 Aug 2007 15:31:20 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1INZRg-000111-87 for bug-gnu-emacs@gnu.org; Tue, 21 Aug 2007 15:31:20 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1INZRg-00010y-4V for bug-gnu-emacs@gnu.org; Tue, 21 Aug 2007 15:31:20 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1INZRg-00032L-SN for bug-gnu-emacs@gnu.org; Tue, 21 Aug 2007 15:31:21 -0400 Original-Received: from rgm by fencepost.gnu.org with local (Exim 4.60) (envelope-from ) id 1INZVg-0000iQ-1K; Tue, 21 Aug 2007 15:35:28 -0400 X-Spook: fissionable Ermes CIDA Ft. Meade Perl-RSA Manfurov $400 X-Ran: m~C7RhXTHD}|&fxpriu\Rh]&&jRa0=Uo}][>_9DDhMwrY2>W[2PEVN{E"!##&j6_Y*A;.r X-Hue: yellow X-Attribution: GM In-Reply-To: <46CAFBEF.2040606@gmx.net> (Martin von Gagern's message of "Tue, 21 Aug 2007 16:51:27 +0200") User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) X-Detected-Kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:16412 Archived-At: How about this: *** files.el 8 Aug 2007 14:06:01 -0000 1.896.2.15 --- files.el 21 Aug 2007 19:25:34 -0000 *************** *** 3120,3126 **** (file-error nil)))))) (defun backup-buffer-copy (from-name to-name modes) ! (let ((umask (default-file-modes))) (unwind-protect (progn ;; Create temp files with strict access rights. It's easy to --- 3120,3131 ---- (file-error nil)))))) (defun backup-buffer-copy (from-name to-name modes) ! (let ((umask (default-file-modes)) ! (dir (or (file-name-directory to-name) ! default-directory))) ! ;; Can't delete or create files in a read-only directory. ! (unless (file-writable-p dir) ! (signal 'file-error (list "Directory is not writable" dir))) (unwind-protect (progn ;; Create temp files with strict access rights. It's easy to *************** *** 3129,3142 **** (set-default-file-modes ?\700) (while (condition-case () (progn ! (condition-case nil ! (delete-file to-name) ! (file-error nil)) (copy-file from-name to-name nil t) nil) (file-already-exists t)) ;; The file was somehow created by someone else between ;; `delete-file' and `copy-file', so let's try again. nil)) ;; Reset the umask. (set-default-file-modes umask))) --- 3134,3149 ---- (set-default-file-modes ?\700) (while (condition-case () (progn ! ;; Failure to delete an existing file is an error. ! (if (file-exists-p to-name) ! (delete-file to-name)) (copy-file from-name to-name nil t) nil) (file-already-exists t)) ;; The file was somehow created by someone else between ;; `delete-file' and `copy-file', so let's try again. + ;; FIXME does that every actually happen in practice? + ;; This is a potential infloop, which seems bad... nil)) ;; Reset the umask. (set-default-file-modes umask)))