From 57adf425f511b90153f128e7679b5f432df13fb5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20H=C3=B6tzel?= Date: Thu, 13 Aug 2015 20:59:16 +0200 Subject: [PATCH] ; Fix caching problem in tramp-adb.el * lisp/net/tramp-adb.el (tramp-adb-handle-directory-files-and-attributes): Make a copy of result to prevent modification of the tramp-cache by side effects. Use the correct cache key. --- lisp/net/tramp-adb.el | 71 ++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index d04d8f63af1..ca76f626b13 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -394,41 +394,42 @@ pass to the OPERATION." "Like `directory-files-and-attributes' for Tramp files." (when (file-directory-p directory) (with-parsed-tramp-file-name (expand-file-name directory) nil - (with-tramp-file-property - v localname (format "directory-files-attributes-%s-%s-%s-%s" - full match id-format nosort) - (with-current-buffer (tramp-get-buffer v) - (when (tramp-adb-send-command-and-check - v (format "%s -a -l %s" - (tramp-adb-get-ls-command v) - (tramp-shell-quote-argument localname))) - ;; We insert also filename/. and filename/.., because "ls" doesn't. - (narrow-to-region (point) (point)) - (tramp-adb-send-command - v (format "%s -d -a -l %s %s" - (tramp-adb-get-ls-command v) - (tramp-shell-quote-argument - (concat (file-name-as-directory localname) ".")) - (tramp-shell-quote-argument - (concat (file-name-as-directory localname) "..")))) - (widen)) - (tramp-adb-sh-fix-ls-output) - (let ((result (tramp-do-parse-file-attributes-with-ls - v (or id-format 'integer)))) - (when full - (setq result - (mapcar - (lambda (x) - (cons (expand-file-name (car x) directory) (cdr x))) - result))) - (unless nosort - (setq result - (sort result (lambda (x y) (string< (car x) (car y)))))) - (delq nil - (mapcar (lambda (x) - (if (or (not match) (string-match match (car x))) - x)) - result)))))))) + (copy-tree + (with-tramp-file-property + v localname (format "directory-files-and-attributes-%s-%s-%s-%s" + full match id-format nosort) + (with-current-buffer (tramp-get-buffer v) + (when (tramp-adb-send-command-and-check + v (format "%s -a -l %s" + (tramp-adb-get-ls-command v) + (tramp-shell-quote-argument localname))) + ;; We insert also filename/. and filename/.., because "ls" doesn't. + (narrow-to-region (point) (point)) + (tramp-adb-send-command + v (format "%s -d -a -l %s %s" + (tramp-adb-get-ls-command v) + (tramp-shell-quote-argument + (concat (file-name-as-directory localname) ".")) + (tramp-shell-quote-argument + (concat (file-name-as-directory localname) "..")))) + (widen)) + (tramp-adb-sh-fix-ls-output) + (let ((result (tramp-do-parse-file-attributes-with-ls + v (or id-format 'integer)))) + (when full + (setq result + (mapcar + (lambda (x) + (cons (expand-file-name (car x) directory) (cdr x))) + result))) + (unless nosort + (setq result + (sort result (lambda (x y) (string< (car x) (car y)))))) + (delq nil + (mapcar (lambda (x) + (if (or (not match) (string-match match (car x))) + x)) + result))))))))) (defun tramp-adb-get-ls-command (vec) (with-tramp-connection-property vec "ls" -- 2.39.2