]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix Bug#31068
authorMichael Albinus <michael.albinus@gmx.de>
Tue, 15 May 2018 09:06:18 +0000 (11:06 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Tue, 15 May 2018 09:06:18 +0000 (11:06 +0200)
* lisp/net/tramp-archive.el (tramp-archive-file-name-handler):
Unregister unless `tramp-archive-enabled'.  (Bug#31068)

lisp/net/tramp-archive.el

index 448cfca2ca17abccb41dbf57b195f7610ab8d86d..42c3d40c1bb6855e74f5b65d0a728e21f8381212 100644 (file)
 (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 ()