From: Michael Albinus Date: Tue, 15 May 2018 09:06:18 +0000 (+0200) Subject: Fix Bug#31068 X-Git-Tag: emacs-27.0.90~5037 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c595d5dd00980975286391151181883a8c71742d;p=emacs.git Fix Bug#31068 * lisp/net/tramp-archive.el (tramp-archive-file-name-handler): Unregister unless `tramp-archive-enabled'. (Bug#31068) --- diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el index 448cfca2ca1..42c3d40c1bb 100644 --- a/lisp/net/tramp-archive.el +++ b/lisp/net/tramp-archive.el @@ -117,7 +117,7 @@ (defvar url-tramp-protocols) ;; We cannot check `tramp-gvfs-enabled' in loaddefs.el, because this -;; would load Tramp. So we make a cheaper check. +;; would load Tramp. So we make a cheaper check. ;;;###autoload (defvar tramp-archive-enabled (featurep 'dbusbind) "Non-nil when file archive support is available.") @@ -302,27 +302,33 @@ pass to the OPERATION." "Invoke the file archive related OPERATION. First arg specifies the OPERATION, second arg is a list of arguments to pass to the OPERATION." - (let* ((filename (apply 'tramp-archive-file-name-for-operation - operation args)) - (archive (tramp-archive-file-name-archive filename))) - ;; The file archive could be a directory, see Bug#30293. - (if (and archive - (tramp-archive-run-real-handler 'file-directory-p (list archive))) - (tramp-archive-run-real-handler operation args) - ;; Now run the handler. - (unless tramp-archive-enabled - (tramp-user-error nil "Package `tramp-archive' not supported")) - (let ((tramp-methods (cons `(,tramp-archive-method) tramp-methods)) - (tramp-gvfs-methods tramp-archive-all-gvfs-methods) - ;; Set uid and gid. gvfsd-archive could do it, but it doesn't. - (tramp-unknown-id-integer (user-uid)) - (tramp-unknown-id-string (user-login-name)) - (fn (assoc operation tramp-archive-file-name-handler-alist))) - (when (eq (cdr fn) 'tramp-archive-handle-not-implemented) - (setq args (cons operation args))) - (if fn - (save-match-data (apply (cdr fn) args)) - (tramp-archive-run-real-handler operation args)))))) + (if (not tramp-archive-enabled) + ;; Unregister `tramp-archive-file-name-handler'. + (progn + (tramp-register-file-name-handlers) + (tramp-archive-run-real-handler operation args)) + + (let* ((filename (apply 'tramp-archive-file-name-for-operation + operation args)) + (archive (tramp-archive-file-name-archive filename))) + + ;; The file archive could be a directory, see Bug#30293. + (if (and archive + (tramp-archive-run-real-handler + 'file-directory-p (list archive))) + (tramp-archive-run-real-handler operation args) + ;; Now run the handler. + (let ((tramp-methods (cons `(,tramp-archive-method) tramp-methods)) + (tramp-gvfs-methods tramp-archive-all-gvfs-methods) + ;; Set uid and gid. gvfsd-archive could do it, but it doesn't. + (tramp-unknown-id-integer (user-uid)) + (tramp-unknown-id-string (user-login-name)) + (fn (assoc operation tramp-archive-file-name-handler-alist))) + (when (eq (cdr fn) 'tramp-archive-handle-not-implemented) + (setq args (cons operation args))) + (if fn + (save-match-data (apply (cdr fn) args)) + (tramp-archive-run-real-handler operation args))))))) ;;;###autoload (progn (defun tramp-register-archive-file-name-handler ()