[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: backup-buffer-copy loops if old backup can't be deleted

From: Martin von Gagern
Subject: Re: backup-buffer-copy loops if old backup can't be deleted
Date: Wed, 22 Aug 2007 00:21:58 +0200
User-agent: Thunderbird (X11/20070817)

martin rudalics wrote:
> Why can't we use
> (copy-file from-name to-name t t)
> here as in Emacs 21?

Good question. Especially since this recreates FILE~ every time.
I can think of at least two scenarios where this could be a problem:

1. The dir is not writable, but the backup file is.
   Here the current behaviour will loop and even with the suggested fix
   it will fall back to ~/%backup%~ unnecessarily.

2. The backup file is a hard link at should remain such.
   This could be wanted in cases where the primary file is a hard link
   as well. Don't know how backup-by-rename would handle this.

I originally assumed that emacs would try backup-buffer-copy only after
figuring out that it could not write to the existing backup file, but it
seems I was wrong there, at least if I read backup-buffer correctly.

So I think we want both, first try to reuse the backup file, which
copy-file with ok-if-exists set to t seems to do well. If that fails, we
can assume the file exists, but we are not allowed to write it, so maybe
we can delete it and create it anew. For this we ned the delete followed
by a copy.

Whether we should do any looping in case something goes wrong is another
question. Another process touching the same file just at the critical
moment should be rare situations. I think having the backup fall back
instead of risking a loop would be acceptable in these cases. An
alternative might be to retry a fixed number of times, say 10, and
assume some permanent problem in the logic if we still don't succeed.
Problem is that this approach might bugs go unnoticed more easily, but
with all those different systems out there, there might always be a
combination that we didn't foresee, so a sane default there might be
worth it.

 Martin von Gagern

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]