(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.")
"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 ()