aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2020-02-13 16:34:41 +0100
committerMichael Albinus2020-02-13 16:34:41 +0100
commit5b160b39c43b7e3d4e377832c306e2e48b53e7e1 (patch)
treeb2b424723a65cccb4e54c36c889eb85e27b2cbe8
parent7fda39419296cda9ae1c01c8ca69a30775db68b0 (diff)
downloademacs-5b160b39c43b7e3d4e377832c306e2e48b53e7e1.tar.gz
emacs-5b160b39c43b7e3d4e377832c306e2e48b53e7e1.zip
Simplify Tramp caching
* lisp/net/tramp-cache.el (tramp-flush-file-upper-properties) (tramp-flush-directory-properties) (tramp-flush-connection-properties, tramp-list-connections) (tramp-parse-connection-properties): * lisp/net/tramp-gvfs.el (tramp-parse-goa-accounts) (tramp-parse-media-names): Simplify cache handling.
-rw-r--r--lisp/net/tramp-cache.el70
-rw-r--r--lisp/net/tramp-gvfs.el37
2 files changed, 44 insertions, 63 deletions
diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el
index 94eeb83ba34..91ed5465695 100644
--- a/lisp/net/tramp-cache.el
+++ b/lisp/net/tramp-cache.el
@@ -197,13 +197,11 @@ Returns VALUE."
197 key (copy-tramp-file-name key)) 197 key (copy-tramp-file-name key))
198 (setf (tramp-file-name-localname key) file 198 (setf (tramp-file-name-localname key) file
199 (tramp-file-name-hop key) nil) 199 (tramp-file-name-hop key) nil)
200 (maphash 200 (dolist (property (hash-table-keys (tramp-get-hash-table key)))
201 (lambda (property _value) 201 (when (string-match-p
202 (when (string-match-p 202 "^\\(directory-\\|file-name-all-completions\\|file-entries\\)"
203 "^\\(directory-\\|file-name-all-completions\\|file-entries\\)" 203 property)
204 property) 204 (tramp-flush-file-property key file property))))))
205 (tramp-flush-file-property key file property)))
206 (tramp-get-hash-table key)))))
207 205
208;;;###tramp-autoload 206;;;###tramp-autoload
209(defun tramp-flush-file-properties (key file) 207(defun tramp-flush-file-properties (key file)
@@ -234,14 +232,12 @@ Remove also properties of all files in subdirectories."
234 #'directory-file-name (list directory))) 232 #'directory-file-name (list directory)))
235 (truename (tramp-get-file-property key directory "file-truename" nil))) 233 (truename (tramp-get-file-property key directory "file-truename" nil)))
236 (tramp-message key 8 "%s" directory) 234 (tramp-message key 8 "%s" directory)
237 (maphash 235 (dolist (key (hash-table-keys tramp-cache-data))
238 (lambda (key _value) 236 (when (and (tramp-file-name-p key)
239 (when (and (tramp-file-name-p key) 237 (stringp (tramp-file-name-localname key))
240 (stringp (tramp-file-name-localname key)) 238 (string-match-p (regexp-quote directory)
241 (string-match-p (regexp-quote directory) 239 (tramp-file-name-localname key)))
242 (tramp-file-name-localname key))) 240 (remhash key tramp-cache-data)))
243 (remhash key tramp-cache-data)))
244 tramp-cache-data)
245 ;; Remove file properties of symlinks. 241 ;; Remove file properties of symlinks.
246 (when (and (stringp truename) 242 (when (and (stringp truename)
247 (not (string-equal directory (directory-file-name truename)))) 243 (not (string-equal directory (directory-file-name truename))))
@@ -365,11 +361,8 @@ used to cache connection properties of the local machine."
365 (tramp-file-name-hop key) nil)) 361 (tramp-file-name-hop key) nil))
366 (tramp-message 362 (tramp-message
367 key 7 "%s %s" key 363 key 7 "%s %s" key
368 (let ((hash (gethash key tramp-cache-data)) 364 (let ((hash (gethash key tramp-cache-data)))
369 properties) 365 (when (hash-table-p hash) (hash-table-keys hash))))
370 (when (hash-table-p hash)
371 (maphash (lambda (x _y) (push x properties)) hash))
372 properties))
373 (setq tramp-cache-data-changed t) 366 (setq tramp-cache-data-changed t)
374 (remhash key tramp-cache-data)) 367 (remhash key tramp-cache-data))
375 368
@@ -411,16 +404,14 @@ used to cache connection properties of the local machine."
411;;;###tramp-autoload 404;;;###tramp-autoload
412(defun tramp-list-connections () 405(defun tramp-list-connections ()
413 "Return all known `tramp-file-name' structs according to `tramp-cache'." 406 "Return all known `tramp-file-name' structs according to `tramp-cache'."
414 (let ((tramp-verbose 0) 407 (let ((tramp-verbose 0))
415 result) 408 (delq nil (mapcar
416 (maphash 409 (lambda (key)
417 (lambda (key _value) 410 (and (tramp-file-name-p key)
418 (when (and (tramp-file-name-p key) 411 (null (tramp-file-name-localname key))
419 (null (tramp-file-name-localname key)) 412 (tramp-connection-property-p key "process-buffer")
420 (tramp-connection-property-p key "process-buffer")) 413 key))
421 (push key result))) 414 (hash-table-keys tramp-cache-data)))))
422 tramp-cache-data)
423 result))
424 415
425(defun tramp-dump-connection-properties () 416(defun tramp-dump-connection-properties ()
426 "Write persistent connection properties into file `tramp-persistency-file-name'." 417 "Write persistent connection properties into file `tramp-persistency-file-name'."
@@ -481,17 +472,14 @@ used to cache connection properties of the local machine."
481 "Return a list of (user host) tuples allowed to access for METHOD. 472 "Return a list of (user host) tuples allowed to access for METHOD.
482This function is added always in `tramp-get-completion-function' 473This function is added always in `tramp-get-completion-function'
483for all methods. Resulting data are derived from connection history." 474for all methods. Resulting data are derived from connection history."
484 (let (res) 475 (mapcar
485 (maphash 476 (lambda (key)
486 (lambda (key _value) 477 (and (tramp-file-name-p key)
487 (if (and (tramp-file-name-p key) 478 (string-equal method (tramp-file-name-method key))
488 (string-equal method (tramp-file-name-method key)) 479 (not (tramp-file-name-localname key))
489 (not (tramp-file-name-localname key))) 480 (list (tramp-file-name-user key)
490 (push (list (tramp-file-name-user key) 481 (tramp-file-name-host key))))
491 (tramp-file-name-host key)) 482 (hash-table-keys tramp-cache-data)))
492 res)))
493 tramp-cache-data)
494 res))
495 483
496;; When "emacs -Q" has been called, both variables are nil. We do not 484;; When "emacs -Q" has been called, both variables are nil. We do not
497;; load the persistency file then, in order to have a clean test environment. 485;; load the persistency file then, in order to have a clean test environment.
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 0d800cb42b3..762c4fe4b3b 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -2345,16 +2345,13 @@ It checks for registered GNOME Online Accounts."
2345 ;; SERVICE might be encoded as a DNS-SD service. 2345 ;; SERVICE might be encoded as a DNS-SD service.
2346 (and (string-match tramp-dns-sd-service-regexp service) 2346 (and (string-match tramp-dns-sd-service-regexp service)
2347 (setq service (match-string 1 service))) 2347 (setq service (match-string 1 service)))
2348 (let (result) 2348 (mapcar
2349 (maphash 2349 (lambda (key)
2350 (lambda (key _value) 2350 (and (tramp-goa-account-p key)
2351 (if (and (tramp-goa-account-p key) 2351 (string-equal service (tramp-goa-account-method key))
2352 (string-equal service (tramp-goa-account-method key))) 2352 (list (tramp-goa-account-user key)
2353 (push (list (tramp-goa-account-user key) 2353 (tramp-goa-account-host key))))
2354 (tramp-goa-account-host key)) 2354 (hash-table-keys tramp-cache-data)))
2355 result)))
2356 tramp-cache-data)
2357 result))
2358 2355
2359 2356
2360;; Media devices functions. 2357;; Media devices functions.
@@ -2407,18 +2404,14 @@ It checks for mounted media devices."
2407 ;; SERVICE might be encoded as a DNS-SD service. 2404 ;; SERVICE might be encoded as a DNS-SD service.
2408 (and (string-match tramp-dns-sd-service-regexp service) 2405 (and (string-match tramp-dns-sd-service-regexp service)
2409 (setq service (match-string 1 service))) 2406 (setq service (match-string 1 service)))
2410 (let (result) 2407 (mapcar
2411 (maphash 2408 (lambda (key)
2412 (lambda (key _value) 2409 (and (tramp-media-device-p key)
2413 (if (and (tramp-media-device-p key) 2410 (string-equal service (tramp-media-device-method key))
2414 (string-equal service (tramp-media-device-method key)) 2411 (tramp-get-connection-property key "vector" nil)
2415 (tramp-get-connection-property key "vector" nil)) 2412 (list nil (tramp-file-name-host
2416 (push 2413 (tramp-get-connection-property key "vector" nil)))))
2417 (list nil (tramp-file-name-host 2414 (hash-table-keys tramp-cache-data)))
2418 (tramp-get-connection-property key "vector" nil)))
2419 result)))
2420 tramp-cache-data)
2421 result))
2422 2415
2423 2416
2424;; D-Bus zeroconf functions. 2417;; D-Bus zeroconf functions.