;;; 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>
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))
(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
(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)
;;;###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)
(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)))
"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)
"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)
(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))
(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))))