]> code.delx.au - gnu-emacs/blobdiff - lisp/net/tramp-cache.el
* net/ange-ftp.el (ange-ftp-get-passwd): Bind
[gnu-emacs] / lisp / net / tramp-cache.el
index 9397025cb601a28f8a6275c142294472f1fabeda..fe5eb0049d089c82a1a8272303842237d2d329a5 100644 (file)
@@ -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 <daniel@inanna.danann.net>
 ;;         Michael Albinus <michael.albinus@gmx.de>
@@ -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)))
@@ -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)
@@ -323,11 +328,17 @@ 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)))
+          (if (and (vectorp key)
+                   (not (tramp-file-name-localname key))
+                   (not (gethash "login-as" value)))
               (progn
                 (remhash "process-name" value)
                 (remhash "process-buffer" value)
@@ -383,7 +394,8 @@ for all methods.  Resulting data are derived from connection history."
           ;; 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 init-file-user site-run-file))
+          (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)