Mercurial > emacs
changeset 108183:b67d7273ec18
Avoid using trash for certain temp files (Bug#6070).
* server.el (server-sentinel, server-start, server-force-delete):
* jka-compr.el (jka-compr-partial-uncompress)
(jka-compr-call-process, jka-compr-write-region, jka-compr-load):
* epg.el (epg--make-temp-file, epg-decrypt-string)
(epg-encrypt-string, epg-verify-string, epg-sign-string):
* diff.el (diff-sentinel): Bind delete-by-moving-to-trash to nil
before deleting (Bug#6070).
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Fri, 30 Apr 2010 22:19:40 -0400 |
parents | 7aa45e6e5f62 |
children | f4b0e5358091 |
files | lisp/ChangeLog lisp/diff.el lisp/epg.el lisp/jka-compr.el lisp/server.el |
diffstat | 5 files changed, 42 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Fri Apr 30 21:39:58 2010 -0400 +++ b/lisp/ChangeLog Fri Apr 30 22:19:40 2010 -0400 @@ -1,3 +1,16 @@ +2010-05-01 Chong Yidong <cyd@stupidchicken.com> + + * server.el (server-sentinel, server-start, server-force-delete): + + * jka-compr.el (jka-compr-partial-uncompress) + (jka-compr-call-process, jka-compr-write-region, jka-compr-load): + + * epg.el (epg--make-temp-file, epg-decrypt-string) + (epg-encrypt-string, epg-verify-string, epg-sign-string): + + * diff.el (diff-sentinel): Bind delete-by-moving-to-trash to nil + before deleting (Bug#6070). + 2010-05-01 Stefan Monnier <monnier@iro.umontreal.ca> * bindings.el (mode-line-abbrev-mode, mode-line-auto-fill-mode):
--- a/lisp/diff.el Fri Apr 30 21:39:58 2010 -0400 +++ b/lisp/diff.el Fri Apr 30 22:19:40 2010 -0400 @@ -64,8 +64,9 @@ "Code run when the diff process exits. CODE is the exit code of the process. It should be 0 only if no diffs were found." - (if diff-old-temp-file (delete-file diff-old-temp-file)) - (if diff-new-temp-file (delete-file diff-new-temp-file)) + (let (delete-by-moving-to-trash) + (if diff-old-temp-file (delete-file diff-old-temp-file)) + (if diff-new-temp-file (delete-file diff-new-temp-file))) (save-excursion (goto-char (point-max)) (let ((inhibit-read-only t))
--- a/lisp/epg.el Fri Apr 30 21:39:58 2010 -0400 +++ b/lisp/epg.el Fri Apr 30 22:19:40 2010 -0400 @@ -1898,7 +1898,8 @@ ;; Cleanup the tempfile. (and tempfile (file-exists-p tempfile) - (delete-file tempfile)) + (let (delete-by-moving-to-trash) + (delete-file tempfile))) ;; Cleanup the tempdir. (and tempdir (file-directory-p tempdir) @@ -1998,7 +1999,8 @@ (epg-read-output context)) (epg-delete-output-file context) (if (file-exists-p input-file) - (delete-file input-file)) + (let (delete-by-moving-to-trash) + (delete-file input-file))) (epg-reset context)))) (defun epg-start-verify (context signature &optional signed-text) @@ -2095,7 +2097,8 @@ (epg-delete-output-file context) (if (and input-file (file-exists-p input-file)) - (delete-file input-file)) + (let (delete-by-moving-to-trash) + (delete-file input-file))) (epg-reset context)))) (defun epg-start-sign (context plain &optional mode) @@ -2202,7 +2205,8 @@ (epg-read-output context)) (epg-delete-output-file context) (if input-file - (delete-file input-file)) + (let (delete-by-moving-to-trash) + (delete-file input-file))) (epg-reset context)))) (defun epg-start-encrypt (context plain recipients @@ -2322,7 +2326,8 @@ (epg-read-output context)) (epg-delete-output-file context) (if input-file - (delete-file input-file)) + (let (delete-by-moving-to-trash) + (delete-file input-file))) (epg-reset context)))) (defun epg-start-export-keys (context keys)
--- a/lisp/jka-compr.el Fri Apr 30 21:39:58 2010 -0400 +++ b/lisp/jka-compr.el Fri Apr 30 22:19:40 2010 -0400 @@ -181,7 +181,9 @@ null-device)) jka-compr-acceptable-retval-list) (jka-compr-error prog args infile message err-file)) - (jka-compr-delete-temp-file err-file))) + (let (delete-by-moving-to-trash) + (delete-file err-file)))) + ;; Run the uncompression program directly. ;; We get the whole file and must delete what we don't want. (jka-compr-call-process prog message infile t nil args)) @@ -222,7 +224,8 @@ ""))) jka-compr-acceptable-retval-list) (jka-compr-error prog args infile message err-file)) - (jka-compr-delete-temp-file err-file))) + (let (delete-by-moving-to-trash) + (delete-file err-file)))) (or (eq 0 (apply 'call-process prog infile (if (stringp output) temp output) @@ -248,9 +251,6 @@ "This routine will return the name of a new file." (make-temp-file jka-compr-temp-name-template)) -(defalias 'jka-compr-delete-temp-file 'delete-file) - - (defun jka-compr-write-region (start end file &optional append visit) (let* ((filename (expand-file-name file)) (visit-file (if (stringp visit) (expand-file-name visit) filename)) @@ -337,7 +337,8 @@ (and append can-append) 'dont)) (erase-buffer)) ) - (jka-compr-delete-temp-file temp-file) + (let (delete-by-moving-to-trash) + (delete-file temp-file)) (and compress-message @@ -603,7 +604,8 @@ (setq file (file-name-sans-extension file))) (setcar l file))) - (jka-compr-delete-temp-file local-copy)) + (let (delete-by-moving-to-trash) + (delete-file local-copy))) t))
--- a/lisp/server.el Fri Apr 30 21:39:58 2010 -0400 +++ b/lisp/server.el Fri Apr 30 22:19:40 2010 -0400 @@ -344,7 +344,9 @@ ;; for possible servers before doing anything, so it *should* be ours. (and (process-contact proc :server) (eq (process-status proc) 'closed) - (ignore-errors (delete-file (process-get proc :server-file)))) + (ignore-errors + (let (delete-by-moving-to-trash) + (delete-file (process-get proc :server-file))))) (server-log (format "Status changed to %s: %s" (process-status proc) msg) proc) (server-delete-client proc)) @@ -517,7 +519,9 @@ ;; Delete the socket files made by previous server invocations. (if (not (eq t (server-running-p server-name))) ;; Remove any leftover socket or authentication file - (ignore-errors (delete-file server-file)) + (ignore-errors + (let (delete-by-moving-to-trash) + (delete-file server-file))) (setq server-mode nil) ;; already set by the minor mode code (display-warning 'server @@ -600,7 +604,7 @@ server-auth-dir server-socket-dir)))) (condition-case nil - (progn + (let (delete-by-moving-to-trash) (delete-file file) (message "Connection file %S deleted" file)) (file-error