aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMichael Albinus2018-01-31 15:02:46 +0100
committerMichael Albinus2018-01-31 15:02:46 +0100
commit84d066a73fc4191a675c87c81ec1a4f531375e95 (patch)
tree8afdbd551f972a149e69c999f9f0e088994cf229 /lisp
parent843f3d4f34c2f54fac19d97c32399671f98ccc51 (diff)
downloademacs-84d066a73fc4191a675c87c81ec1a4f531375e95.tar.gz
emacs-84d066a73fc4191a675c87c81ec1a4f531375e95.zip
Fix Bug#30293
* lisp/net/tramp-archive.el (tramp-archive-file-name-for-operation): New defsubst. (tramp-archive-file-name-archive, tramp-archive-file-name-localname): New defuns. (tramp-archive-file-name-handler, tramp-archive-dissect-file-name) (tramp-archive-handle-not-implemented): Use them. (Bug#30293) * test/lisp/net/tramp-archive-tests.el (tramp-archive-test-directory): New defconst. (tramp-archive-test01-file-name-syntax): Extend test. (tramp-archive-test05-expand-file-name-non-archive-directory): New test. (Bug#30293) * test/lisp/net/tramp-archive-resources/foo.iso/foo: New file.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/net/tramp-archive.el49
1 files changed, 35 insertions, 14 deletions
diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el
index 51ee18fac7a..8d292e16023 100644
--- a/lisp/net/tramp-archive.el
+++ b/lisp/net/tramp-archive.el
@@ -253,21 +253,33 @@ It must be supported by libarchive(3).")
253 "Alist of handler functions for GVFS archive method. 253 "Alist of handler functions for GVFS archive method.
254Operations not mentioned here will be handled by the default Emacs primitives.") 254Operations not mentioned here will be handled by the default Emacs primitives.")
255 255
256(defsubst tramp-archive-file-name-for-operation (operation &rest args)
257 "Like `tramp-file-name-for-operation', but for archive file name syntax."
258 (cl-letf (((symbol-function 'tramp-tramp-file-p) 'tramp-archive-file-name-p))
259 (apply 'tramp-file-name-for-operation operation args)))
260
256;;;###tramp-autoload 261;;;###tramp-autoload
257(defun tramp-archive-file-name-handler (operation &rest args) 262(defun tramp-archive-file-name-handler (operation &rest args)
258 "Invoke the GVFS archive related OPERATION. 263 "Invoke the GVFS archive related OPERATION.
259First arg specifies the OPERATION, second arg is a list of arguments to 264First arg specifies the OPERATION, second arg is a list of arguments to
260pass to the OPERATION." 265pass to the OPERATION."
261 (unless tramp-gvfs-enabled 266 (let* ((filename (apply 'tramp-archive-file-name-for-operation
262 (tramp-compat-user-error nil "Package `tramp-archive' not supported")) 267 operation args))
263 (let ((tramp-methods (cons `(,tramp-archive-method) tramp-methods)) 268 (archive (tramp-archive-file-name-archive filename)))
264 (tramp-gvfs-methods tramp-archive-all-gvfs-methods) 269 ;; The file archive could be a directory, see Bug#30293.
265 (fn (assoc operation tramp-archive-file-name-handler-alist))) 270 (if (file-directory-p archive)
266 (when (eq (cdr fn) 'tramp-archive-handle-not-implemented) 271 (tramp-run-real-handler operation args)
267 (setq args (cons operation args))) 272 ;; Now run the handler.
268 (if fn 273 (unless tramp-gvfs-enabled
269 (save-match-data (apply (cdr fn) args)) 274 (tramp-compat-user-error nil "Package `tramp-archive' not supported"))
270 (tramp-run-real-handler operation args)))) 275 (let ((tramp-methods (cons `(,tramp-archive-method) tramp-methods))
276 (tramp-gvfs-methods tramp-archive-all-gvfs-methods)
277 (fn (assoc operation tramp-archive-file-name-handler-alist)))
278 (when (eq (cdr fn) 'tramp-archive-handle-not-implemented)
279 (setq args (cons operation args)))
280 (if fn
281 (save-match-data (apply (cdr fn) args))
282 (tramp-run-real-handler operation args))))))
271 283
272;; Mark `operations' the handler is responsible for. 284;; Mark `operations' the handler is responsible for.
273(put 'tramp-archive-file-name-handler 'operations 285(put 'tramp-archive-file-name-handler 'operations
@@ -300,6 +312,16 @@ pass to the OPERATION."
300 (string-match tramp-archive-file-name-regexp name) 312 (string-match tramp-archive-file-name-regexp name)
301 t)) 313 t))
302 314
315(defun tramp-archive-file-name-archive (name)
316 "Return archive part of NAME."
317 (and (tramp-archive-file-name-p name)
318 (match-string 1 name)))
319
320(defun tramp-archive-file-name-localname (name)
321 "Return localname part of NAME."
322 (and (tramp-archive-file-name-p name)
323 (match-string 2 name)))
324
303(defvar tramp-archive-hash (make-hash-table :test 'equal) 325(defvar tramp-archive-hash (make-hash-table :test 'equal)
304 "Hash table for archive local copies. 326 "Hash table for archive local copies.
305The hash key is the archive name. The value is a cons of the 327The hash key is the archive name. The value is a cons of the
@@ -314,9 +336,8 @@ name is kept in slot `hop'"
314 (save-match-data 336 (save-match-data
315 (unless (tramp-archive-file-name-p name) 337 (unless (tramp-archive-file-name-p name)
316 (tramp-compat-user-error nil "Not an archive file name: \"%s\"" name)) 338 (tramp-compat-user-error nil "Not an archive file name: \"%s\"" name))
317 ;; The `string-match' happened in `tramp-archive-file-name-p'. 339 (let* ((localname (tramp-archive-file-name-localname name))
318 (let* ((localname (match-string 2 name)) 340 (archive (file-truename (tramp-archive-file-name-archive name)))
319 (archive (file-truename (match-string 1 name)))
320 (vec (make-tramp-file-name 341 (vec (make-tramp-file-name
321 :method tramp-archive-method :hop archive))) 342 :method tramp-archive-method :hop archive)))
322 343
@@ -535,7 +556,7 @@ offered."
535 "Generic handler for operations not implemented for file archives." 556 "Generic handler for operations not implemented for file archives."
536 (let ((v (ignore-errors 557 (let ((v (ignore-errors
537 (tramp-archive-dissect-file-name 558 (tramp-archive-dissect-file-name
538 (apply 'tramp-file-name-for-operation operation args))))) 559 (apply 'tramp-archive-file-name-for-operation operation args)))))
539 (tramp-message v 10 "%s" (cons operation args)) 560 (tramp-message v 10 "%s" (cons operation args))
540 (tramp-error 561 (tramp-error
541 v 'file-error 562 v 'file-error