X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/0f6990a78ae5016d8ae73253cdb4739adf0197e7..493c66882d491bcd6178e580abea92787f3e1555:/lisp/net/tramp-cache.el diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el index e3e6264b28..fe5eb0049d 100644 --- a/lisp/net/tramp-cache.el +++ b/lisp/net/tramp-cache.el @@ -1,6 +1,6 @@ ;;; tramp-cache.el --- file information caching for Tramp -;; Copyright (C) 2000, 2005-2011 Free Software Foundation, Inc. +;; Copyright (C) 2000, 2005-2012 Free Software Foundation, Inc. ;; Author: Daniel Pittman ;; Michael Albinus @@ -162,6 +162,11 @@ FILE must be a local file name on a connection identified via VEC." ;;;###tramp-autoload (defun tramp-flush-file-property (vec file) "Remove all properties of FILE in the cache context of VEC." + ;; Remove file property of symlinks. + (let ((truename (tramp-get-file-property vec file "file-truename" nil))) + (when (and (stringp truename) + (not (string-equal file truename))) + (tramp-flush-file-property vec truename))) ;; Unify localname. (setq vec (copy-sequence vec)) (aset vec 3 (tramp-run-real-handler 'directory-file-name (list file))) @@ -177,9 +182,9 @@ Remove also properties of all files in subdirectories." (tramp-message vec 8 "%s" directory) (maphash (lambda (key value) - (when (and (stringp (tramp-file-name-localname key)) - (string-match directory (tramp-file-name-localname key))) - (remhash key tramp-cache-data))) + (when (and (stringp (tramp-file-name-localname key)) + (string-match directory (tramp-file-name-localname key))) + (remhash key tramp-cache-data))) tramp-cache-data))) ;; Reverting or killing a buffer should also flush file properties. @@ -200,12 +205,12 @@ Remove also properties of all files in subdirectories." (add-hook 'kill-buffer-hook 'tramp-flush-file-function) (add-hook 'tramp-cache-unload-hook (lambda () - (remove-hook 'before-revert-hook - 'tramp-flush-file-function) - (remove-hook 'eshell-pre-command-hook - 'tramp-flush-file-function) - (remove-hook 'kill-buffer-hook - 'tramp-flush-file-function))) + (remove-hook 'before-revert-hook + 'tramp-flush-file-function) + (remove-hook 'eshell-pre-command-hook + 'tramp-flush-file-function) + (remove-hook 'kill-buffer-hook + 'tramp-flush-file-function))) ;;; -- Properties -- @@ -238,7 +243,7 @@ PROPERTY is set persistent when KEY is a vector." (aset key 3 nil)) (let ((hash (or (gethash key tramp-cache-data) (puthash key (make-hash-table :test 'equal) - tramp-cache-data)))) + tramp-cache-data)))) (puthash property value hash) (setq tramp-cache-data-changed t) (tramp-message key 7 "%s %s" property value) @@ -290,17 +295,17 @@ KEY identifies the connection, it is either a process or a vector." (let (result) (maphash (lambda (key value) - (let ((tmp (format - "(%s %s)" - (if (processp key) - (prin1-to-string (prin1-to-string key)) - (prin1-to-string key)) - (if (hash-table-p value) - (tramp-cache-print value) - (if (bufferp value) - (prin1-to-string (prin1-to-string value)) - (prin1-to-string value)))))) - (setq result (if result (concat result " " tmp) tmp)))) + (let ((tmp (format + "(%s %s)" + (if (processp key) + (prin1-to-string (prin1-to-string key)) + (prin1-to-string key)) + (if (hash-table-p value) + (tramp-cache-print value) + (if (bufferp value) + (prin1-to-string (prin1-to-string value)) + (prin1-to-string value)))))) + (setq result (if result (concat result " " tmp) tmp)))) table) result))) @@ -310,8 +315,8 @@ KEY identifies the connection, it is either a process or a vector." (let (result) (maphash (lambda (key value) - (when (and (vectorp key) (null (aref key 3))) - (add-to-list 'result key))) + (when (and (vectorp key) (null (aref key 3))) + (add-to-list 'result key))) tramp-cache-data) result)) @@ -323,16 +328,22 @@ KEY identifies the connection, it is either a process or a vector." (not (zerop (hash-table-count tramp-cache-data))) tramp-cache-data-changed (stringp tramp-persistency-file-name)) - (let ((cache (copy-hash-table tramp-cache-data))) - ;; Remove temporary data. + (let ((cache (copy-hash-table tramp-cache-data)) + print-length print-level) + ;; Remove temporary data. If there is the key "login-as", we + ;; don't save either, because all other properties might + ;; depend on the login name, and we want to give the + ;; possibility to use another login name later on. (maphash (lambda (key value) - (if (and (vectorp key) (not (tramp-file-name-localname key))) - (progn - (remhash "process-name" value) - (remhash "process-buffer" value) - (remhash "first-password-request" value)) - (remhash key cache))) + (if (and (vectorp key) + (not (tramp-file-name-localname key)) + (not (gethash "login-as" value))) + (progn + (remhash "process-name" value) + (remhash "process-buffer" value) + (remhash "first-password-request" value)) + (remhash key cache))) cache) ;; Dump it. (with-temp-buffer @@ -357,8 +368,8 @@ KEY identifies the connection, it is either a process or a vector." (add-hook 'kill-emacs-hook 'tramp-dump-connection-properties)) (add-hook 'tramp-cache-unload-hook (lambda () - (remove-hook 'kill-emacs-hook - 'tramp-dump-connection-properties))) + (remove-hook 'kill-emacs-hook + 'tramp-dump-connection-properties))) ;;;###tramp-autoload (defun tramp-parse-connection-properties (method) @@ -368,18 +379,23 @@ for all methods. Resulting data are derived from connection history." (let (res) (maphash (lambda (key value) - (if (and (vectorp key) - (string-equal method (tramp-file-name-method key)) - (not (tramp-file-name-localname key))) - (push (list (tramp-file-name-user key) - (tramp-file-name-host key)) - res))) + (if (and (vectorp key) + (string-equal method (tramp-file-name-method key)) + (not (tramp-file-name-localname key))) + (push (list (tramp-file-name-user key) + (tramp-file-name-host key)) + res))) tramp-cache-data) res)) ;; Read persistent connection history. (when (and (stringp tramp-persistency-file-name) - (zerop (hash-table-count tramp-cache-data))) + (zerop (hash-table-count tramp-cache-data)) + ;; When "emacs -Q" has been called, both variables are nil. + ;; We do not load the persistency file then, in order to + ;; have a clean test environment. + (or (and (boundp 'init-file-user) (symbol-value 'init-file-user)) + (and (boundp 'site-run-file) (symbol-value 'site-run-file)))) (condition-case err (with-temp-buffer (insert-file-contents tramp-persistency-file-name)