emacs-devel
[Top][All Lists]
Advanced

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

Trouble with backing up files


From: Eli Zaretskii
Subject: Trouble with backing up files
Date: Sun, 24 Apr 2005 15:21:08 +0300

These recent changes:

        (backup-buffer-copy, basic-save-buffer-2): Take care against
        writing thru an unexpected existing symlink.

break saving of precious files (those for which file-precious-flag is
non-nil): Emacs always says that it cannot backup the file, and tries
to back it up in ~/%backup%~ (which also fails: it creates an empty
file by that name, but doesn't write the original file's contents
there).

I tracked the problem to this snippet in backup-buffer-copy:

          (while (condition-case ()
                     (progn
                       (condition-case nil
                           (delete-file to-name)
                         (file-error nil))
                       (write-region "" nil to-name nil 'silent nil 'excl)
                       nil)
                   (file-already-exists t))
            ;; the file was somehow created by someone else between
            ;; `make-temp-name' and `write-region', let's try again.
            nil)
          (copy-file from-name to-name t t 'excl))

This deletes the destination file to-name, then creates an empty file
by the same name.  It then attempts to copy the material from the
original file from-name by calling copy-file with the new arg
MUSTBENEW set to `excl', which of course fails, since we just created
a file by that name when write-region was called.

For now, I fixed this by removing the `excl' arg from the call to
copy-file, but I'm not sure this is the right fix, since this is the
only place where copy-file is called with that argument, and so the
reason for introducing it is unclear.

Richard, could you please explain why you made those changes and
perhaps also say a few words about the implementation, including the
need for the new optional arg of copy-file?




reply via email to

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