Use a version for the Tramp cache
* lisp/net/tramp-cache.el (tramp-cache-version): New defconst. (top): Check the cache version, and flush the cache in case of mismatch. Suggested by Paul Pogonyshev <pogonyshev@gmail.com>. * lisp/net/tramp-cmds.el (tramp-cleanup-all-connections): Re-initialize the cache version.
This commit is contained in:
parent
55f46cc77c
commit
405466b79c
2 changed files with 24 additions and 2 deletions
|
@ -28,7 +28,7 @@
|
|||
;; An implementation of information caching for remote files.
|
||||
|
||||
;; Each connection, identified by a `tramp-file-name' structure or by
|
||||
;; a process, has a unique cache. We distinguish 5 kind of caches,
|
||||
;; a process, has a unique cache. We distinguish 6 kind of caches,
|
||||
;; depending on the key:
|
||||
;;
|
||||
;; - localname is nil. These are reusable properties. Examples:
|
||||
|
@ -56,6 +56,10 @@
|
|||
;; "{uid,gid}-{integer,string}" are the local uid and gid, and
|
||||
;; "locale" is the used shell locale.
|
||||
;;
|
||||
;; - The key is `tramp-cache-version'. It keeps the Tramp version the
|
||||
;; cache data was produced with. If the cache is read by another
|
||||
;; Tramp version, it is flushed.
|
||||
;;
|
||||
;; - The key is `tramp-cache-undefined'. All functions return the
|
||||
;; expected values, but nothing is cached.
|
||||
|
||||
|
@ -105,6 +109,10 @@ details see the info pages."
|
|||
:group 'tramp
|
||||
:type 'file)
|
||||
|
||||
;;;###tramp-autoload
|
||||
(defconst tramp-cache-version (make-tramp-file-name :method "cache")
|
||||
"Virtual connection vector for Tramp version.")
|
||||
|
||||
(defvar tramp-cache-data-changed nil
|
||||
"Whether persistent cache data have been changed.")
|
||||
|
||||
|
@ -632,9 +640,16 @@ for all methods. Resulting data are derived from connection history."
|
|||
;; initialized properly by side effect.
|
||||
(unless (tramp-connection-property-p key (car item))
|
||||
(tramp-set-connection-property key (pop item) (car item)))))))
|
||||
;; Check Tramp version. Clear cache in case of mismatch.
|
||||
(unless (string-equal
|
||||
(tramp-get-connection-property
|
||||
tramp-cache-version "tramp-version" "")
|
||||
tramp-version)
|
||||
(signal 'file-error nil))
|
||||
(setq tramp-cache-data-changed nil))
|
||||
(file-error
|
||||
;; Most likely because the file doesn't exist yet. No message.
|
||||
;; Most likely because the file doesn't exist yet, or the Tramp
|
||||
;; version doesn't match. No message.
|
||||
(clrhash tramp-cache-data))
|
||||
(error
|
||||
;; File is corrupted.
|
||||
|
@ -642,6 +657,9 @@ for all methods. Resulting data are derived from connection history."
|
|||
tramp-persistency-file-name (error-message-string err))
|
||||
(clrhash tramp-cache-data))))
|
||||
|
||||
;; Initialize the cache version.
|
||||
(tramp-set-connection-property tramp-cache-version "tramp-version" tramp-version)
|
||||
|
||||
(add-hook 'tramp-unload-hook
|
||||
(lambda ()
|
||||
(unload-feature 'tramp-cache 'force)))
|
||||
|
|
|
@ -179,6 +179,10 @@ This includes password cache, file cache, connection cache, buffers."
|
|||
;; Flush file and connection cache.
|
||||
(clrhash tramp-cache-data)
|
||||
|
||||
;; Initialize the cache version.
|
||||
(tramp-set-connection-property
|
||||
tramp-cache-version "tramp-version" tramp-version)
|
||||
|
||||
;; Remove ad-hoc proxies.
|
||||
(let ((proxies tramp-default-proxies-alist))
|
||||
(while proxies
|
||||
|
|
Loading…
Add table
Reference in a new issue