~ushin/ushin#138: 
Potentially confusing/data-loss behavior regarding saving deleted entries

  1. Make entry.
  2. Open entry in buffer.
  3. Delete entry from directory buffer.
  4. C-x C-s in entry's buffer.
  5. Emacs says, "(No changes need to be saved)", even though the entry no longer exists on the hyperdrive, and it does not save the file again. With a local file, after deleting it with delete-file, Emacs re-saves the buffer to the file.

So it appears that when the user calls save-buffer, we need to check whether the entry exists before refusing to save what appears to be an unmodified buffer. (This check is currently happening in Emacs but not in our code.)

Status
RESOLVED FIXED
Submitter
~alphapapa
Assigned to
No-one
Submitted
5 months ago
Updated
4 months ago
Labels
0.2.0 hyperdrive.el

~ushin 5 months ago*

basic-save-buffer does this:

(if (or (buffer-modified-p)
        ;; Handle the case when no modification has been made but
        ;; the file disappeared since visited.
        (and buffer-file-name
	     (not (file-exists-p buffer-file-name))))
    ;; Other logic, including write-contents-functions
    )

meaning that there's no way for hyperdrive--write-contents to run when buffer-modified-p returns nil.

I think the best course of action is to iterate through the buffer list after deleting a file/directory and call (set-buffer-modified-p) on each buffer visiting a deleted file.

Perhaps in a hook?

~ushin REPORTED FIXED 4 months ago

Fixed in 5d3d0cf9

Register here or Log in to comment, or comment via email.