]> code.delx.au - gnu-emacs/blobdiff - lisp/net/tramp-cache.el
* etc/AUTHORS: Update the AUTHORS file
[gnu-emacs] / lisp / net / tramp-cache.el
index 1e24ea53f43a0bec3a74cfb210da61486ff188ca..26825ffa2dd88864d1c22ff538a009b8ff01ff37 100644 (file)
@@ -1,6 +1,6 @@
 ;;; tramp-cache.el --- file information caching for Tramp
 
-;; Copyright (C) 2000, 2005-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2005-2016 Free Software Foundation, Inc.
 
 ;; Author: Daniel Pittman <daniel@inanna.danann.net>
 ;;         Michael Albinus <michael.albinus@gmx.de>
@@ -66,7 +66,8 @@
 Every entry has the form (REGEXP PROPERTY VALUE).  The regexp
 matches remote file names.  It can be nil.  PROPERTY is a string,
 and VALUE the corresponding value.  They are used, if there is no
-matching entry for PROPERTY in `tramp-cache-data'."
+matching entry for PROPERTY in `tramp-cache-data'.  For more
+details see the info pages."
   :group 'tramp
   :version "24.4"
   :type '(repeat (list (choice :tag "File Name regexp" regexp (const nil))
@@ -120,9 +121,10 @@ matching entries of `tramp-connection-properties'."
 (defun tramp-get-file-property (key file property default)
   "Get the PROPERTY of FILE from the cache context of KEY.
 Returns DEFAULT if not set."
-  ;; Unify localname.
+  ;; Unify localname.  Remove hop from vector.
   (setq key (copy-sequence key))
   (aset key 3 (tramp-run-real-handler 'directory-file-name (list file)))
+  (aset key 4 nil)
   (let* ((hash (tramp-get-hash-table key))
         (value (when (hash-table-p hash) (gethash property hash))))
     (if
@@ -152,9 +154,10 @@ Returns DEFAULT if not set."
 (defun tramp-set-file-property (key file property value)
   "Set the PROPERTY of FILE to VALUE, in the cache context of KEY.
 Returns VALUE."
-  ;; Unify localname.
+  ;; Unify localname.  Remove hop from vector.
   (setq key (copy-sequence key))
   (aset key 3 (tramp-run-real-handler 'directory-file-name (list file)))
+  (aset key 4 nil)
   (let ((hash (tramp-get-hash-table key)))
     ;; We put the timestamp there.
     (puthash property (cons (current-time) value) hash)
@@ -168,16 +171,19 @@ Returns VALUE."
 ;;;###tramp-autoload
 (defun tramp-flush-file-property (key file)
   "Remove all properties of FILE in the cache context of KEY."
-  ;; Remove file properties of symlinks.
-  (let ((truename (tramp-get-file-property key file "file-truename" nil)))
+  (let* ((file (tramp-run-real-handler
+               'directory-file-name (list file)))
+        (truename (tramp-get-file-property key file "file-truename" nil)))
+    ;; Remove file properties of symlinks.
     (when (and (stringp truename)
-              (not (string-equal file truename)))
-      (tramp-flush-file-property key truename)))
-  ;; Unify localname.
-  (setq key (copy-sequence key))
-  (aset key 3 (tramp-run-real-handler 'directory-file-name (list file)))
-  (tramp-message key 8 "%s" file)
-  (remhash key tramp-cache-data))
+              (not (string-equal file (directory-file-name truename))))
+      (tramp-flush-file-property key truename))
+    ;; Unify localname.  Remove hop from vector.
+    (setq key (copy-sequence key))
+    (aset key 3 file)
+    (aset key 4 nil)
+    (tramp-message key 8 "%s" file)
+    (remhash key tramp-cache-data)))
 
 ;;;###tramp-autoload
 (defun tramp-flush-directory-property (key directory)
@@ -188,13 +194,14 @@ Remove also properties of all files in subdirectories."
         (truename (tramp-get-file-property key directory "file-truename" nil)))
     ;; Remove file properties of symlinks.
     (when (and (stringp truename)
-              (not (string-equal directory truename)))
+              (not (string-equal directory (directory-file-name truename))))
       (tramp-flush-directory-property key truename))
     (tramp-message key 8 "%s" directory)
     (maphash
      (lambda (key _value)
        (when (and (stringp (tramp-file-name-localname key))
-                 (string-match directory (tramp-file-name-localname key)))
+                 (string-match (regexp-quote directory)
+                               (tramp-file-name-localname key)))
         (remhash key tramp-cache-data)))
      tramp-cache-data)))
 
@@ -236,11 +243,12 @@ This is suppressed for temporary buffers."
   "Get the named PROPERTY for the connection.
 KEY identifies the connection, it is either a process or a vector.
 If the value is not set for the connection, returns DEFAULT."
-  ;; Unify key by removing localname from vector.  Work with a copy in
-  ;; order to avoid side effects.
+  ;; Unify key by removing localname and hop from vector.  Work with a
+  ;; copy in order to avoid side effects.
   (when (vectorp key)
     (setq key (copy-sequence key))
-    (aset key 3 nil))
+    (aset key 3 nil)
+    (aset key 4 nil))
   (let* ((hash (tramp-get-hash-table key))
         (value (if (hash-table-p hash)
                    (gethash property hash default)
@@ -253,11 +261,12 @@ If the value is not set for the connection, returns DEFAULT."
   "Set the named PROPERTY of a connection to VALUE.
 KEY identifies the connection, it is either a process or a vector.
 PROPERTY is set persistent when KEY is a vector."
-  ;; Unify key by removing localname from vector.  Work with a copy in
-  ;; order to avoid side effects.
+  ;; Unify key by removing localname and hop from vector.  Work with a
+  ;; copy in order to avoid side effects.
   (when (vectorp key)
     (setq key (copy-sequence key))
-    (aset key 3 nil))
+    (aset key 3 nil)
+    (aset key 4 nil))
   (let ((hash (tramp-get-hash-table key)))
     (puthash property value hash)
     (setq tramp-cache-data-changed t)
@@ -274,11 +283,12 @@ KEY identifies the connection, it is either a process or a vector."
 (defun tramp-flush-connection-property (key)
   "Remove all properties identified by KEY.
 KEY identifies the connection, it is either a process or a vector."
-  ;; Unify key by removing localname from vector.  Work with a copy in
-  ;; order to avoid side effects.
+  ;; Unify key by removing localname and hop from vector.  Work with a
+  ;; copy in order to avoid side effects.
   (when (vectorp key)
     (setq key (copy-sequence key))
-    (aset key 3 nil))
+    (aset key 3 nil)
+    (aset key 4 nil))
   (tramp-message
    key 7 "%s %s" key
    (let ((hash (gethash key tramp-cache-data))
@@ -430,7 +440,7 @@ for all methods.  Resulting data are derived from connection history."
      (clrhash tramp-cache-data))
     (error
      ;; File is corrupted.
-     (message "Tramp persistency file '%s' is corrupted: %s"
+     (message "Tramp persistency file `%s' is corrupted: %s"
              tramp-persistency-file-name (error-message-string err))
      (clrhash tramp-cache-data))))