[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: File cleared when remote disk is full
From: |
Michael Albinus |
Subject: |
Re: File cleared when remote disk is full |
Date: |
Wed, 05 Dec 2012 14:48:19 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Qiang Li <address@hidden> writes:
> I was editing a remote file using scp protocol while the remote disk
> got full, and when I saved the file it silently became empty on the
> disk. I happened to notice this before I close Emacs, so I had the
> chance to write the buffer to another file. I think this behavior is
> dangerous and should be classified as a bug.
Thanks for the report. I've added some return code checking for
out-of-band copying. Note, that this does not work when your local
system is running MS Windows - I don't know hot to check a return code
in cmd.exe. Does anybody know?
Alternatively, you can already now set `file-precious-flag' to `t'.
Tramp performs additional checks, and would warn you in case the copy
operation does not succeed. Since these checks slow down Tramp, they are
not ebabled by default.
> p.s. I was using TRAMP coming with Emacs 24.2 (debian sid)
Here's the patch I have prepared for Tramp 2.2.7-pre. It shall apply for
Emacs 24.2 as well, modulo changed line numbers.
--8<---------------cut here---------------start------------->8---
*** ~/src/tramp/lisp/tramp-sh.el.~master~ 2012-12-05 14:42:21.435686599
+0100
--- ~/src/tramp/lisp/tramp-sh.el 2012-12-05 14:37:54.734907100 +0100
***************
*** 2379,2395 ****
;; last longer than 60 secs.
(let ((p (let ((default-directory
(tramp-compat-temporary-file-directory)))
! (apply 'start-process
(tramp-get-connection-name v)
(tramp-get-connection-buffer v)
copy-program
! (append copy-args (list source target))))))
(tramp-message
orig-vec 6 "%s"
(mapconcat 'identity (process-command p) " "))
(tramp-compat-set-process-query-on-exit-flag p nil)
(tramp-process-actions
! p v nil tramp-actions-copy-out-of-band)))
;; Reset the transfer process properties.
(tramp-message orig-vec 6 "\n%s" (buffer-string))
--- 2379,2419 ----
;; last longer than 60 secs.
(let ((p (let ((default-directory
(tramp-compat-temporary-file-directory)))
! (apply 'start-process-shell-command
(tramp-get-connection-name v)
(tramp-get-connection-buffer v)
copy-program
! (append
! copy-args
! (list
! (shell-quote-argument source)
! (shell-quote-argument target))
! (unless (memq system-type '(windows-nt))
! '(";" "echo"
! "tramp_exit_status" "$?")))))))
(tramp-message
orig-vec 6 "%s"
(mapconcat 'identity (process-command p) " "))
(tramp-compat-set-process-query-on-exit-flag p nil)
(tramp-process-actions
! p v nil tramp-actions-copy-out-of-band)
!
! ;; Check the return code. This does not work under
! ;; MS Windows.
! (unless (memq system-type '(windows-nt))
! (goto-char (point-max))
! (unless
! (re-search-backward "tramp_exit_status [0-9]+" nil t)
! (tramp-error
! orig-vec 'file-error
! "Couldn't find exit status of `%s'" (process-command p)))
! (skip-chars-forward "^ ")
! (unless (zerop (read (current-buffer)))
! (forward-line -1)
! (tramp-error
! orig-vec 'file-error
! "Error copying: `%s'"
! (buffer-substring (point-min) (point-at-eol)))))))
;; Reset the transfer process properties.
(tramp-message orig-vec 6 "\n%s" (buffer-string))
--8<---------------cut here---------------end--------------->8---
Best regards, Michael.