From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Martin von Gagern Newsgroups: gmane.emacs.bugs Subject: Re: backup-buffer-copy loops if old backup can't be deleted Date: Wed, 22 Aug 2007 11:13:18 +0200 Message-ID: <46CBFE2E.9050606@gmx.net> References: <46CAD810.3050904@gmx.net> <46CAF8AC.9070809@gmx.at> <46CAFBEF.2040606@gmx.net> <46CB529F.7010008@gmx.at> <16sl6cy2t8.fsf@fencepost.gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0208414877==" X-Trace: sea.gmane.org 1187774017 32104 80.91.229.12 (22 Aug 2007 09:13:37 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 22 Aug 2007 09:13:37 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org To: Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Aug 22 11:13:35 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 1INmHO-000205-PL for geb-bug-gnu-emacs@m.gmane.org; Wed, 22 Aug 2007 11:13:35 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1INmHN-0001Xi-Bh for geb-bug-gnu-emacs@m.gmane.org; Wed, 22 Aug 2007 05:13:33 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1INmHJ-0001Vc-Nb for bug-gnu-emacs@gnu.org; Wed, 22 Aug 2007 05:13:29 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1INmHH-0001TN-Ow for bug-gnu-emacs@gnu.org; Wed, 22 Aug 2007 05:13:29 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1INmHH-0001Sz-Gf for bug-gnu-emacs@gnu.org; Wed, 22 Aug 2007 05:13:27 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1INmHH-0008Uc-3K for bug-gnu-emacs@gnu.org; Wed, 22 Aug 2007 05:13:27 -0400 Original-Received: (qmail invoked by alias); 22 Aug 2007 09:13:25 -0000 Original-Received: from ppp-88-217-44-103.dynamic.mnet-online.de (EHLO [88.217.44.103]) [88.217.44.103] by mail.gmx.net (mp029) with SMTP; 22 Aug 2007 11:13:25 +0200 X-Authenticated: #858129 X-Provags-ID: V01U2FsdGVkX1/O999kWM/OI27WOOOOhx7JAdN9cDtDSKug0UB3Gi zH+84KHNcNExc3 User-Agent: Thunderbird 2.0.0.6 (X11/20070817) In-Reply-To: <16sl6cy2t8.fsf@fencepost.gnu.org> X-Enigmail-Version: 0.95.3 X-Y-GMX-Trusted: 0 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:16417 Archived-At: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --===============0208414877== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig411C103757729DA8858AC9B5" This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig411C103757729DA8858AC9B5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Glenn Morris wrote: > ! (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))) This seems a good idea, as deleting a backup file we won't be able to recreate would be a bad move. However I guess there are filesystems out there where a file might be undeletable even if its directory is writable. So be careful about assumptions. You should still be careful about exception handling later on. > + ;; If we allow for the possibility of somethin= g > + ;; creating the file between delete and copy > + ;; (below), we must also allow for the > + ;; possibility of something deleting it betwee= n > + ;; a file-exists-p check and a delete. > (condition-case nil > (delete-file to-name) > (file-error nil)) You left the possible cause for the loop in place, again relying on catching an error in the normal course of events when there is no backup. I can see your point, but I still think this is dangerous. One reason is given above, and the second reason is this: If we keep thinking about other processes creating or deleting files in the middle of the operation, we might as well consider other processes changing permissions as well. So who says that the directory will still be writable once we are here? Is there some reliable way by which we could discern a file-error because the file does not exist from a file-error because we can't delete it? Because we can recover from one, but not from the other. > + ;; FIXME does that every actually happen in practice? > + ;; This is a potential infloop, which seems bad... The more I think about it, the rarer this seems to me. In my last mail I voted for a fixed maximum loop count, but by now I would even drop all loops; they are simply not worth the effort I guess. Greetings, Martin von Gagern --------------enig411C103757729DA8858AC9B5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGy/4zRhp6o4m9dFsRAki6AKCB+AR/dwKV2N+6x/XiUpBVNlFZEwCghoxo my10NKOMUgGzi1DBYvT+DYY= =QciA -----END PGP SIGNATURE----- --------------enig411C103757729DA8858AC9B5-- --===============0208414877== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ bug-gnu-emacs mailing list bug-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs --===============0208414877==--