2018-11-24 13:01:36 +00:00
|
|
|
|
;;; tramp-rclone.el --- Tramp access functions to cloud storages -*- lexical-binding:t -*-
|
|
|
|
|
|
2024-01-02 01:47:10 +00:00
|
|
|
|
;; Copyright (C) 2018-2024 Free Software Foundation, Inc.
|
2018-11-24 13:01:36 +00:00
|
|
|
|
|
|
|
|
|
;; Author: Michael Albinus <michael.albinus@gmx.de>
|
|
|
|
|
;; Keywords: comm, processes
|
|
|
|
|
;; Package: tramp
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; rclone is a command line program to sync files and directories to
|
|
|
|
|
;; and from cloud storages. Tramp uses its mount utility to access
|
|
|
|
|
;; files and directories there. The configuration of rclone for
|
|
|
|
|
;; different storage systems is performed outside Tramp, see rclone(1).
|
|
|
|
|
|
|
|
|
|
;; A remote file under rclone control has the form
|
|
|
|
|
;; "/rclone:<remote>:/path/to/file". <remote> is the name of a
|
|
|
|
|
;; storage system in rclone's configuration. Therefore, such a remote
|
2018-12-07 16:21:03 +00:00
|
|
|
|
;; file name does not know of any user or port specification.
|
2018-11-24 13:01:36 +00:00
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
(require 'tramp)
|
2021-03-08 11:05:29 +00:00
|
|
|
|
(require 'tramp-fuse)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
|
|
|
|
|
;;;###tramp-autoload
|
|
|
|
|
(defconst tramp-rclone-method "rclone"
|
|
|
|
|
"When this method name is used, forward all calls to rclone mounts.")
|
|
|
|
|
|
|
|
|
|
(defcustom tramp-rclone-program "rclone"
|
|
|
|
|
"Name of the rclone program."
|
|
|
|
|
:group 'tramp
|
|
|
|
|
:version "27.1"
|
Add convenience to Tramp
* doc/misc/tramp.texi (Inline methods): Add tramp-docker-program,
tramp-podman-program, tramp-kubernetes-program,
tramp-toolbox-program, tramp-distrobox-program,
tramp-flatpak-program, tramp-apptainer-program, and
tramp-nspawn-program.
(Remote shell setup): Rearrange indices.
(Ssh setup): Say "user option" when needed.
(Keeping files encrypted): Add tramp-crypt-encfs-program.
(Frequently Asked Questions): Rearrange indices. Remove duplicate
text. Add tramp-mode.
* lisp/net/tramp.el (tramp-active-command-completion-p): New defun.
* lisp/net/tramp-cmds.el (tramp-cleanup-connection)
(tramp-cleanup-all-connections, tramp-cleanup-some-buffers)
(tramp-cleanup-all-buffers, tramp-rename-files):
* lisp/net/tramp-message.el (tramp-setup-debug-buffer):
Declare `completion'.
* lisp/net/tramp-integration.el (tramp-info-link): New widget.
(tramp-widget-info-link-action): New defun.
* lisp/net/tramp.el (tramp, tramp-mode, tramp-backup-directory-alist)
(tramp-auto-save-directory, tramp-encoding-shell)
(tramp-encoding-command-switch)
(tramp-encoding-command-interactive, tramp-default-method)
(tramp-default-method-alist, tramp-default-user)
(tramp-default-user-alist, tramp-default-host)
(tramp-default-host-alist, tramp-default-proxies-alist)
(tramp-save-ad-hoc-proxies, tramp-show-ad-hoc-proxies)
(tramp-restricted-shell-hosts-alist, tramp-local-host-regexp)
(tramp-shell-prompt-pattern, tramp-password-prompt-regexp)
(tramp-otp-password-prompt-regexp, tramp-wrong-passwd-regexp)
(tramp-terminal-type, tramp-syntax)
(tramp-ignored-file-name-regexp, tramp-chunksize)
(tramp-process-connection-type, tramp-remote-path)
(tramp-remote-process-environment)
(tramp-completion-multi-hop-methods)
(tramp-completion-use-auth-sources, tramp-use-file-attributes)
(tramp-inhibit-errors-if-setting-file-attributes-fail)
(tramp-allow-unsafe-temporary-files):
* lisp/net/tramp-adb.el (tramp-adb-program)
(tramp-adb-connect-if-not-connected):
* lisp/net/tramp-cache.el (tramp-connection-properties)
(tramp-persistency-file-name, tramp-completion-use-cache):
* lisp/net/tramp-cmds.el (tramp-cleanup-some-buffers-hook)
(tramp-default-rename-alist, tramp-confirm-rename-file-names)
(tramp-file-name-with-method):
* lisp/net/tramp-container.el (tramp-docker-program)
(tramp-podman-program, tramp-kubernetes-program)
(tramp-kubernetes-context, tramp-kubernetes-namespace)
(tramp-toolbox-program, tramp-distrobox-program)
(tramp-flatpak-program, tramp-apptainer-program)
(tramp-nspawn-program):
* lisp/net/tramp-crypt.el (tramp-crypt-encfs-program)
(tramp-crypt-encfsctl-program, tramp-crypt-encfs-option)
(tramp-crypt-save-encfs-config-remote):
* lisp/net/tramp-fuse.el (tramp-fuse-unmount-on-cleanup):
* lisp/net/tramp-gvfs.el (tramp-gvfs-methods):
* lisp/net/tramp-message.el (tramp-verbose, tramp-debug-to-file)
(tramp-debug-command-messages):
* lisp/net/tramp-rclone.el (tramp-rclone-program):
* lisp/net/tramp-sh.el (tramp-inline-compress-start-size)
(tramp-copy-size-limit, tramp-histfile-override)
(tramp-use-connection-share)
(tramp-use-scp-direct-remote-copying, tramp-sh-extra-args):
* lisp/net/tramp-sshfs.el (tramp-sshfs-program): Add `:link' key.
* lisp/net/tramp.el (tramp-enable-method): Move function ...
* lisp/net/tramp-cmds.el (tramp-enable-method): ... here.
2024-08-26 16:48:53 +00:00
|
|
|
|
:type 'string
|
|
|
|
|
:link '(info-link :tag "Tramp manual" "(tramp) Setup of rclone method"))
|
2018-11-24 13:01:36 +00:00
|
|
|
|
|
|
|
|
|
;;;###tramp-autoload
|
* lisp/net/tramp: Rework mutual dependencies
Functionally split tramp-loaddefs.el into two parts: one part run
while loading it at the very beginning of loading tramp.el (holding plain
autoloads and declarations), and another run at the very end of loading
tramp.el (holding setup code).
This should reduce infinite-recursion problems while loading.
* lisp/net/tramp.el: Require tramp-loaddefs at beginning.
Run (new and internal) tramp--startup-hook at the end.
Remove all tramp-autoloads. Prefer tramp--with-startup over
eval-after-load.
(tramp--with-startup): New macro.
(tramp-set-syntax): Show the new value rather than the old value in the
error message.
(tramp-syntax-values): Explicitly return 'values'.
(tramp-prefix-format, tramp-prefix-regexp, tramp-method-regexp)
(tramp-postfix-method-format, tramp-postfix-method-regexp)
(tramp-prefix-ipv6-format, tramp-prefix-ipv6-regexp)
(tramp-postfix-ipv6-format, tramp-postfix-ipv6-regexp)
(tramp-postfix-host-format, tramp-postfix-host-regexp)
(tramp-remote-file-name-spec-regexp, tramp-file-name-structure)
(tramp-completion-file-name-regexp): Don't initialize in the declaration,
since it's recomputed at the end anyway.
(tramp-time-dont-know, tramp-time-doesnt-exist): Move before first use.
* lisp/net/tramp-compat.el: Don't require tramp-loaddefs any more.
(tramp-compat-tramp-syntax): Declare tramp-syntax.
* lisp/net/tramp-smb.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-ftp.el:
* lisp/net/tramp-adb.el: Wrap all autoloaded setup operations within
tramp--with-startup.
* lisp/net/tramp-sh.el: Wrap all autoloaded setup operations within
tramp--with-startup.
(tramp-display-escape-sequence-regexp)
(tramp-device-escape-sequence-regexp): Don't tramp-autoload any more.
(tramp-stat-marker): Use eval-and-compile rather than tramp-autoload.
* lisp/net/tramp-sudoedit.el: Wrap all autoloaded setup operations within
tramp--with-startup.
Require tramp-sh at compile-time to precompute some regexps based on
tramp-stat-marker.
2018-12-16 15:32:53 +00:00
|
|
|
|
(tramp--with-startup
|
2019-02-04 15:02:46 +00:00
|
|
|
|
(add-to-list 'tramp-methods
|
|
|
|
|
`(,tramp-rclone-method
|
2021-02-17 17:04:35 +00:00
|
|
|
|
;; Be careful changing "--dir-cache-time", this could
|
|
|
|
|
;; delay visibility of files. Since we use Tramp's
|
|
|
|
|
;; internal cache for file attributes, there shouldn't
|
|
|
|
|
;; be serious performance penalties when set to 0.
|
|
|
|
|
(tramp-mount-args
|
|
|
|
|
("--no-unicode-normalization" "--dir-cache-time" "0s"))
|
2019-02-04 15:02:46 +00:00
|
|
|
|
(tramp-copyto-args nil)
|
|
|
|
|
(tramp-moveto-args nil)
|
|
|
|
|
(tramp-about-args ("--full"))))
|
|
|
|
|
|
|
|
|
|
(add-to-list 'tramp-default-host-alist `(,tramp-rclone-method nil ""))
|
2018-11-24 13:01:36 +00:00
|
|
|
|
|
Reduce autoloaded objects in Tramp
* lisp/net/tramp-adb.el (tramp-adb-program)
(tramp-adb-connect-if-not-connected, tramp-adb-prompt):
Remove autoload cookie.
* lisp/net/tramp-cache.el (tramp-connection-properties)
(tramp-persistency-file-name): Remove autoload cookie.
* lisp/net/tramp-ftp.el (tramp-ftp-enable-ange-ftp):
Use `tramp-autoload' cookie.
* lisp/net/tramp-gvfs.el (tramp-gvfs-zeroconf-domain):
Remove autoload cookie.
* lisp/net/tramp-rclone.el (tramp-rclone-program): Remove autoload
cookie.
(tramp-set-completion-function): Use `tramp--with-startup'.
* lisp/net/tramp-sh.el (tramp-inline-compress-start-size)
(tramp-copy-size-limit, tramp-histfile-override)
(tramp-use-ssh-controlmaster-options, tramp-remote-path)
(tramp-remote-process-environment, tramp-sh-extra-args):
Remove autoload cookie.
(tramp-stat-marker, tramp-stat-quoted-marker): Move to tramp.el.
* lisp/net/tramp-smb.el (tramp-smb-program)
(tramp-smb-acl-program, tramp-smb-conf)
(tramp-smb-winexe-program, tramp-smb-winexe-shell-command)
(tramp-smb-winexe-shell-command-switch): Remove autoload cookie.
* lisp/net/tramp-sudoedit.el (server, tramp-sh): Do not require.
* lisp/net/tramp.el (tramp--startup-hook): Define.
(tramp-stat-marker, tramp-stat-quoted-marker): New defconsts,
taken from tramp-sh.el.
* test/lisp/net/tramp-archive-tests.el (tramp-copy-size-limit)
(tramp-persistency-file-name): Declare.
* test/lisp/net/tramp-tests.el (tramp-connection-properties)
(tramp-display-escape-sequence-regexp)
(tramp-inline-compress-start-size, tramp-remote-path): Declare.
2018-12-17 10:50:06 +00:00
|
|
|
|
(tramp-set-completion-function
|
|
|
|
|
tramp-rclone-method '((tramp-rclone-parse-device-names ""))))
|
2018-11-24 13:01:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; New handlers should be added here.
|
|
|
|
|
;;;###tramp-autoload
|
|
|
|
|
(defconst tramp-rclone-file-name-handler-alist
|
2021-11-15 16:50:15 +00:00
|
|
|
|
'(;; `abbreviate-file-name' performed by default handler.
|
|
|
|
|
(access-file . tramp-handle-access-file)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(add-name-to-file . tramp-handle-add-name-to-file)
|
|
|
|
|
;; `byte-compiler-base-file-name' performed by default handler.
|
2019-11-05 11:58:47 +00:00
|
|
|
|
(copy-directory . tramp-handle-copy-directory)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(copy-file . tramp-rclone-handle-copy-file)
|
2021-03-08 11:05:29 +00:00
|
|
|
|
(delete-directory . tramp-fuse-handle-delete-directory)
|
|
|
|
|
(delete-file . tramp-fuse-handle-delete-file)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
;; `diff-latest-backup-file' performed by default handler.
|
|
|
|
|
(directory-file-name . tramp-handle-directory-file-name)
|
2021-03-08 11:05:29 +00:00
|
|
|
|
(directory-files . tramp-fuse-handle-directory-files)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(directory-files-and-attributes
|
|
|
|
|
. tramp-handle-directory-files-and-attributes)
|
|
|
|
|
(dired-compress-file . ignore)
|
|
|
|
|
(dired-uncache . tramp-handle-dired-uncache)
|
|
|
|
|
(exec-path . ignore)
|
2018-12-07 16:21:03 +00:00
|
|
|
|
(expand-file-name . tramp-handle-expand-file-name)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(file-accessible-directory-p . tramp-handle-file-accessible-directory-p)
|
|
|
|
|
(file-acl . ignore)
|
2021-03-08 11:05:29 +00:00
|
|
|
|
(file-attributes . tramp-fuse-handle-file-attributes)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(file-directory-p . tramp-handle-file-directory-p)
|
|
|
|
|
(file-equal-p . tramp-handle-file-equal-p)
|
2021-03-08 11:05:29 +00:00
|
|
|
|
(file-executable-p . tramp-fuse-handle-file-executable-p)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(file-exists-p . tramp-handle-file-exists-p)
|
2023-05-03 11:26:35 +00:00
|
|
|
|
(file-group-gid . tramp-handle-file-group-gid)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(file-in-directory-p . tramp-handle-file-in-directory-p)
|
2018-12-07 16:21:03 +00:00
|
|
|
|
(file-local-copy . tramp-handle-file-local-copy)
|
Implement file locks for remote files (Bug#49261)
* doc/lispref/files.texi (Magic File Names): Add file-locked-p,
lock-file and unlock-file.
* etc/NEWS: Tramp supports file locks now.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-adb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
* lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-crypt-handle-file-locked-p, tramp-crypt-handle-lock-file)
(tramp-crypt-handle-unlock-file): New defun.
* lisp/net/tramp-fuse.el (tramp-fuse-mounted-p): Simplify.
(tramp-fuse-unmount): New defun.
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-gvfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-rclone-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sh-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-smb-handle-copy-directory): Use `sleep-for'.
(tramp-smb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sshfs-handle-write-region): Handle LOCKNAME.
(tramp-sshfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sudoedit-maybe-open-connection):
Set "lock-pid" connection property.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-make-lock-name, tramp-get-lock-file, tramp-get-lock-pid)
(tramp-handle-file-locked-p, tramp-handle-lock-file)
(tramp-handle-unlock-file): New defuns.
(tramp-lock-file-contents-regexp): New regexp.
(tramp-handle-write-region): Handle LOCKNAME.
* src/filelock.c (lock_file, unlock_file_body, Ffile_locked_p):
Call handler if exists.
(Flock_file, Funlock_file): New defuns.
(Qlock_file, Qunlock_file, Qfile_locked_p): Declare symbols.
(Slock_file, Sunlock_file): Declare subroutines.
* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test40-make-nearby-temp-file)
(tramp-archive-test43-file-system-info): Rename.
* test/lisp/net/tramp-tests.el (top): Set `create-lockfiles' to nil.
(tramp--test-fuse-p): New defun.
(tramp-test14-delete-directory): Use it.
(tramp-test39-lock-file): New test.
(tramp-test40-make-nearby-temp-file)
(tramp-test41-special-characters)
(tramp-test41-special-characters-with-stat)
(tramp-test41-special-characters-with-perl)
(tramp-test41-special-characters-with-ls, tramp-test42-utf8)
(tramp-test42-utf8-with-stat, tramp-test42-utf8-with-perl)
(tramp-test42-utf8-with-ls, tramp-test43-file-system-info)
(tramp-test44-asynchronous-requests, tramp-test45-auto-load)
(tramp-test45-delay-load, tramp-test45-recursive-load)
(tramp-test45-remote-load-path, tramp-test46-unload): Rename.
(tramp--test-special-characters, tramp--test-utf8)
(tramp--test-asynchronous-requests-timeout): Modify docstring.
2021-07-07 16:36:53 +00:00
|
|
|
|
(file-locked-p . tramp-handle-file-locked-p)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(file-modes . tramp-handle-file-modes)
|
2021-03-08 11:05:29 +00:00
|
|
|
|
(file-name-all-completions . tramp-fuse-handle-file-name-all-completions)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(file-name-as-directory . tramp-handle-file-name-as-directory)
|
|
|
|
|
(file-name-case-insensitive-p . tramp-handle-file-name-case-insensitive-p)
|
|
|
|
|
(file-name-completion . tramp-handle-file-name-completion)
|
|
|
|
|
(file-name-directory . tramp-handle-file-name-directory)
|
|
|
|
|
(file-name-nondirectory . tramp-handle-file-name-nondirectory)
|
|
|
|
|
;; `file-name-sans-versions' performed by default handler.
|
|
|
|
|
(file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
|
2022-02-16 19:22:45 +00:00
|
|
|
|
(file-notify-add-watch . tramp-handle-file-notify-add-watch)
|
|
|
|
|
(file-notify-rm-watch . tramp-handle-file-notify-rm-watch)
|
|
|
|
|
(file-notify-valid-p . tramp-handle-file-notify-valid-p)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(file-ownership-preserved-p . ignore)
|
Remove Emacs 25 compatibility from Tramp
* doc/misc/tramp.texi (Remote programs, Remote processes)
(Frequently Asked Questions): Adapt Emacs versions.
* doc/misc/trampver.texi:
* lisp/net/trampver.el: Change version to "2.6.0-pre".
* lisp/net/tramp-adb.el (top): Don't use `tramp-compat-funcall' for
connection-local functions.
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-handle-temporary-file-directory)
(tramp-compat-temporary-file-directory-function)
(tramp-compat-file-attribute-type)
(tramp-compat-file-attribute-link-number)
(tramp-compat-file-attribute-user-id)
(tramp-compat-file-attribute-group-id)
(tramp-compat-file-attribute-access-time)
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-status-change-time)
(tramp-compat-file-attribute-size)
(tramp-compat-file-attribute-modes, tramp-file-missing)
(tramp-compat-file-missing, tramp-compat-file-local-name): Remove.
(tramp-compat-file-name-quoted-p, tramp-compat-file-name-quote)
(tramp-compat-file-name-unquote)
(tramp-compat-progress-reporter-update)
(tramp-compat-file-modes, tramp-compat-set-file-modes)
(tramp-compat-set-file-times, tramp-compat-directory-files)
(tramp-compat-directory-files-and-attributes): Adapt implementation.
* lisp/net/tramp.el:
* lisp/net/tramp-adb.el:
* lisp/net/tramp-archive.el:
* lisp/net/tramp-crypt.el:
* lisp/net/tramp-fuse.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-sh.el:
* lisp/net/tramp-smb.el:
* lisp/net/tramp-sudoedit.el: Adapt callees.
* lisp/net/tramp-crypt.el (tramp-crypt-config-file-name):
Expand file name.
* lisp/net/tramp-fuse.el (tramp-fuse-handle-file-readable-p): Remove.
* lisp/net/tramp-gvfs.el (tramp-gvfs-enabled): Don't check Emacs version.
(tramp-gvfs-handler-mounted-unmounted): Use `make-tramp-file-name'.
* lisp/net/tramp-integration.el (rfn-eshadow-overlay):
Remove declaration.
(top): Don't use `tramp-compat-funcall' for connection-local functions.
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
Use `tramp-rclone-handle-file-readable-p'.
(tramp-rclone-handle-file-readable-p): New defun.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Use `tramp-handle-file-readable-p'.
* lisp/net/tramp.el (tramp-temp-name-prefix, tramp-lookup-syntax):
Adapt docstring.
(tramp-set-connection-local-variables)
(tramp-set-connection-local-variables-for-buffer): Don't use
`tramp-compat-funcall' for connection-local functions.
(tramp-file-name-for-operation): Reorder list.
(tramp-handle-make-symbolic-link): Don't handle TARGET and
OK-IF-ALREADY-EXISTS.
(tramp-read-passwd): Don't use `read-passwd' any longer.
(top): Don't check for `interrupt-process-functions'.
* test/lisp/net/tramp-archive-tests.el (tramp-archive--test-emacs26-p):
Remove.
(tramp-archive-test02-file-name-dissect): Use `make-tramp-file-name'.
(all): Replace Emacs 26 compatibility functions with their
original name.
(tramp-archive-test46-auto-load)
(tramp-archive-test46-delay-load): Rename.
* test/lisp/net/tramp-tests.el (dired-aux, seq): Require them.
(dired-compress, connection-local-criteria-alist)
(connection-local-profile-alist, async-shell-command-width):
Don't declare.
(all): Replace Emacs 26 compatibility functions with their
original name.
(tramp-test04-substitute-in-file-name)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test15-copy-directory)
(tramp-test17-insert-directory)
(tramp-test17-dired-with-wildcards, tramp-test21-file-links)
(tramp-test31-interrupt-process)
(tramp-test34-connection-local-variables)
(tramp-test34-explicit-shell-file-name)
(tramp-test40-make-nearby-temp-file)
(tramp-test41-special-characters, tramp-test42-utf8)
(tramp-test46-delay-load, tramp-test46-remote-load-path)
(tramp-test47-unload): Don't check for Emacs 26 special features.
(tramp--test-emacs26-p): Remove.
(tramp--test-emacs29-p): New defun.
(tramp-test45-dired-compress-file)
(tramp-test45-dired-compress-dir): Use it.
(tramp-test44-asynchronous-requests): Use `seq-random-elt'.
2021-11-12 17:17:32 +00:00
|
|
|
|
(file-readable-p . tramp-rclone-handle-file-readable-p)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(file-regular-p . tramp-handle-file-regular-p)
|
|
|
|
|
(file-remote-p . tramp-handle-file-remote-p)
|
|
|
|
|
(file-selinux-context . tramp-handle-file-selinux-context)
|
|
|
|
|
(file-symlink-p . tramp-handle-file-symlink-p)
|
|
|
|
|
(file-system-info . tramp-rclone-handle-file-system-info)
|
|
|
|
|
(file-truename . tramp-handle-file-truename)
|
2023-01-10 23:35:18 +00:00
|
|
|
|
(file-user-uid . tramp-handle-file-user-uid)
|
2018-12-07 16:21:03 +00:00
|
|
|
|
(file-writable-p . tramp-handle-file-writable-p)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(find-backup-file-name . tramp-handle-find-backup-file-name)
|
|
|
|
|
;; `get-file-buffer' performed by default handler.
|
|
|
|
|
(insert-directory . tramp-handle-insert-directory)
|
|
|
|
|
(insert-file-contents . tramp-handle-insert-file-contents)
|
2022-04-05 15:08:03 +00:00
|
|
|
|
(list-system-processes . ignore)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(load . tramp-handle-load)
|
Implement file locks for remote files (Bug#49261)
* doc/lispref/files.texi (Magic File Names): Add file-locked-p,
lock-file and unlock-file.
* etc/NEWS: Tramp supports file locks now.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-adb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
* lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-crypt-handle-file-locked-p, tramp-crypt-handle-lock-file)
(tramp-crypt-handle-unlock-file): New defun.
* lisp/net/tramp-fuse.el (tramp-fuse-mounted-p): Simplify.
(tramp-fuse-unmount): New defun.
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-gvfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-rclone-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sh-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-smb-handle-copy-directory): Use `sleep-for'.
(tramp-smb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sshfs-handle-write-region): Handle LOCKNAME.
(tramp-sshfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sudoedit-maybe-open-connection):
Set "lock-pid" connection property.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-make-lock-name, tramp-get-lock-file, tramp-get-lock-pid)
(tramp-handle-file-locked-p, tramp-handle-lock-file)
(tramp-handle-unlock-file): New defuns.
(tramp-lock-file-contents-regexp): New regexp.
(tramp-handle-write-region): Handle LOCKNAME.
* src/filelock.c (lock_file, unlock_file_body, Ffile_locked_p):
Call handler if exists.
(Flock_file, Funlock_file): New defuns.
(Qlock_file, Qunlock_file, Qfile_locked_p): Declare symbols.
(Slock_file, Sunlock_file): Declare subroutines.
* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test40-make-nearby-temp-file)
(tramp-archive-test43-file-system-info): Rename.
* test/lisp/net/tramp-tests.el (top): Set `create-lockfiles' to nil.
(tramp--test-fuse-p): New defun.
(tramp-test14-delete-directory): Use it.
(tramp-test39-lock-file): New test.
(tramp-test40-make-nearby-temp-file)
(tramp-test41-special-characters)
(tramp-test41-special-characters-with-stat)
(tramp-test41-special-characters-with-perl)
(tramp-test41-special-characters-with-ls, tramp-test42-utf8)
(tramp-test42-utf8-with-stat, tramp-test42-utf8-with-perl)
(tramp-test42-utf8-with-ls, tramp-test43-file-system-info)
(tramp-test44-asynchronous-requests, tramp-test45-auto-load)
(tramp-test45-delay-load, tramp-test45-recursive-load)
(tramp-test45-remote-load-path, tramp-test46-unload): Rename.
(tramp--test-special-characters, tramp--test-utf8)
(tramp--test-asynchronous-requests-timeout): Modify docstring.
2021-07-07 16:36:53 +00:00
|
|
|
|
(lock-file . tramp-handle-lock-file)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(make-auto-save-file-name . tramp-handle-make-auto-save-file-name)
|
2021-03-08 11:05:29 +00:00
|
|
|
|
(make-directory . tramp-fuse-handle-make-directory)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(make-directory-internal . ignore)
|
2021-07-13 17:50:05 +00:00
|
|
|
|
(make-lock-file-name . tramp-handle-make-lock-file-name)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
|
2018-12-23 08:48:05 +00:00
|
|
|
|
(make-process . ignore)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(make-symbolic-link . tramp-handle-make-symbolic-link)
|
2022-11-27 15:57:03 +00:00
|
|
|
|
(memory-info . ignore)
|
2022-04-05 15:08:03 +00:00
|
|
|
|
(process-attributes . ignore)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(process-file . ignore)
|
|
|
|
|
(rename-file . tramp-rclone-handle-rename-file)
|
|
|
|
|
(set-file-acl . ignore)
|
|
|
|
|
(set-file-modes . ignore)
|
|
|
|
|
(set-file-selinux-context . ignore)
|
|
|
|
|
(set-file-times . ignore)
|
|
|
|
|
(set-visited-file-modtime . tramp-handle-set-visited-file-modtime)
|
|
|
|
|
(shell-command . ignore)
|
|
|
|
|
(start-file-process . ignore)
|
|
|
|
|
(substitute-in-file-name . tramp-handle-substitute-in-file-name)
|
|
|
|
|
(temporary-file-directory . tramp-handle-temporary-file-directory)
|
2022-03-07 12:42:30 +00:00
|
|
|
|
(tramp-get-home-directory . ignore)
|
2020-06-14 13:31:17 +00:00
|
|
|
|
(tramp-get-remote-gid . ignore)
|
2022-09-06 10:33:19 +00:00
|
|
|
|
(tramp-get-remote-groups . ignore)
|
2020-06-14 13:31:17 +00:00
|
|
|
|
(tramp-get-remote-uid . ignore)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(tramp-set-file-uid-gid . ignore)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(unhandled-file-name-directory . ignore)
|
Implement file locks for remote files (Bug#49261)
* doc/lispref/files.texi (Magic File Names): Add file-locked-p,
lock-file and unlock-file.
* etc/NEWS: Tramp supports file locks now.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-adb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
* lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-crypt-handle-file-locked-p, tramp-crypt-handle-lock-file)
(tramp-crypt-handle-unlock-file): New defun.
* lisp/net/tramp-fuse.el (tramp-fuse-mounted-p): Simplify.
(tramp-fuse-unmount): New defun.
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-gvfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-rclone-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sh-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-smb-handle-copy-directory): Use `sleep-for'.
(tramp-smb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sshfs-handle-write-region): Handle LOCKNAME.
(tramp-sshfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sudoedit-maybe-open-connection):
Set "lock-pid" connection property.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-make-lock-name, tramp-get-lock-file, tramp-get-lock-pid)
(tramp-handle-file-locked-p, tramp-handle-lock-file)
(tramp-handle-unlock-file): New defuns.
(tramp-lock-file-contents-regexp): New regexp.
(tramp-handle-write-region): Handle LOCKNAME.
* src/filelock.c (lock_file, unlock_file_body, Ffile_locked_p):
Call handler if exists.
(Flock_file, Funlock_file): New defuns.
(Qlock_file, Qunlock_file, Qfile_locked_p): Declare symbols.
(Slock_file, Sunlock_file): Declare subroutines.
* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test40-make-nearby-temp-file)
(tramp-archive-test43-file-system-info): Rename.
* test/lisp/net/tramp-tests.el (top): Set `create-lockfiles' to nil.
(tramp--test-fuse-p): New defun.
(tramp-test14-delete-directory): Use it.
(tramp-test39-lock-file): New test.
(tramp-test40-make-nearby-temp-file)
(tramp-test41-special-characters)
(tramp-test41-special-characters-with-stat)
(tramp-test41-special-characters-with-perl)
(tramp-test41-special-characters-with-ls, tramp-test42-utf8)
(tramp-test42-utf8-with-stat, tramp-test42-utf8-with-perl)
(tramp-test42-utf8-with-ls, tramp-test43-file-system-info)
(tramp-test44-asynchronous-requests, tramp-test45-auto-load)
(tramp-test45-delay-load, tramp-test45-recursive-load)
(tramp-test45-remote-load-path, tramp-test46-unload): Rename.
(tramp--test-special-characters, tramp--test-utf8)
(tramp--test-asynchronous-requests-timeout): Modify docstring.
2021-07-07 16:36:53 +00:00
|
|
|
|
(unlock-file . tramp-handle-unlock-file)
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(vc-registered . ignore)
|
|
|
|
|
(verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)
|
2018-12-07 16:21:03 +00:00
|
|
|
|
(write-region . tramp-handle-write-region))
|
2018-11-24 13:01:36 +00:00
|
|
|
|
"Alist of handler functions for Tramp RCLONE method.
|
|
|
|
|
Operations not mentioned here will be handled by the default Emacs primitives.")
|
|
|
|
|
|
|
|
|
|
;; It must be a `defsubst' in order to push the whole code into
|
|
|
|
|
;; tramp-loaddefs.el. Otherwise, there would be recursive autoloading.
|
|
|
|
|
;;;###tramp-autoload
|
2021-11-11 18:34:17 +00:00
|
|
|
|
(defsubst tramp-rclone-file-name-p (vec-or-filename)
|
|
|
|
|
"Check if it's a VEC-OR-FILENAME for rclone."
|
2024-10-30 09:39:02 +00:00
|
|
|
|
(and-let* ((vec (tramp-ensure-dissected-file-name vec-or-filename))
|
|
|
|
|
((string= (tramp-file-name-method vec) tramp-rclone-method)))))
|
2018-11-24 13:01:36 +00:00
|
|
|
|
|
|
|
|
|
;;;###tramp-autoload
|
|
|
|
|
(defun tramp-rclone-file-name-handler (operation &rest args)
|
Adapt Tramp docstrings according to checkdoc
* lisp/net/tramp.el (tramp-backup-directory-alist)
(tramp-echoed-echo-mark-regexp, tramp-syntax-values)
(tramp-lookup-syntax, tramp-build-prefix-format)
(tramp-build-prefix-regexp, tramp-build-method-regexp)
(tramp-build-postfix-method-format)
(tramp-build-postfix-method-regexp)
(tramp-build-prefix-ipv6-format, tramp-build-prefix-ipv6-regexp)
(tramp-build-postfix-ipv6-format)
(tramp-build-postfix-ipv6-regexp)
(tramp-build-postfix-host-format)
(tramp-build-postfix-host-regexp, tramp-unknown-id-string)
(tramp-unknown-id-integer, tramp-build-file-name-regexp)
(tramp-build-completion-file-name-regexp, tramp-chunksize)
(tramp-find-method, tramp-find-user, tramp-find-host)
(tramp-dissect-file-name, tramp-get-buffer)
(tramp-get-connection-buffer, tramp-debug-message, tramp-error)
(with-tramp-connection-property, tramp-run-real-handler)
(tramp-file-name-for-operation, tramp-file-name-handler)
(tramp-completion-file-name-handler)
(tramp-completion-handle-file-name-completion)
(tramp-completion-dissect-file-name)
(tramp-completion-dissect-file-name1)
(tramp-handle-file-name-as-directory)
(tramp-handle-file-name-directory)
(tramp-handle-file-name-nondirectory, tramp-mode-string-to-int)
(tramp-file-mode-from-int):
* lisp/net/tramp-adb.el (tramp-adb-file-name-p):
* lisp/net/tramp-archive.el (tramp-archive-run-real-handler)
(tramp-archive-file-name-handler)
(tramp-archive-dissect-file-name)
(with-parsed-tramp-archive-file-name)
(tramp-archive-gvfs-file-name, tramp-archive-handle-access-file):
* lisp/net/tramp-cmds.el (tramp-list-remote-buffers):
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-compat-funcall, tramp-compat-tramp-file-name-slots):
* lisp/net/tramp-ftp.el (tramp-ftp-file-name-handler)
(tramp-ftp-file-name-p):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-p)
(tramp-gvfs-file-name-handler)
(tramp-gvfs-stringify-dbus-message)
(tramp-gvfs-monitor-process-filter)
(tramp-gvfs-handler-mounted-unmounted):
* lisp/net/tramp-integration.el
(tramp-rfn-eshadow-update-overlay-regexp):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-p)
(tramp-rclone-file-name-handler, tramp-rclone-send-command):
* lisp/net/tramp-sh.el (tramp-sh--quoting-style-options)
(tramp-sh-gio-monitor-process-filter)
(tramp-sh-gvfs-monitor-dir-process-filter)
(tramp-sh-inotifywait-process-filter, tramp-find-executable)
(tramp-set-remote-path, tramp-open-shell, tramp-find-shell)
(tramp-send-command-and-check, tramp-shell-case-fold)
(tramp-get-remote-path):
* lisp/net/tramp-smb.el (tramp-smb-file-name-p)
(tramp-smb-file-name-handler)
(tramp-smb-do-file-attributes-with-stat)
(tramp-smb-handle-substitute-in-file-name)
(tramp-smb-get-stat-capability, tramp-smb-shell-quote-argument):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-p)
(tramp-sudoedit-file-name-handler)
(tramp-sudoedit-send-command-string):
* test/lisp/net/tramp-archive-tests.el (tramp-archive-test-all):
* test/lisp/net/tramp-tests.el (tramp--test-gvfs-p)
(tramp--test-with-proper-process-name-and-buffer)
(tramp-test-all): Adapt docstrings according to `checkdoc'.
2019-11-13 12:10:58 +00:00
|
|
|
|
"Invoke the rclone handler for OPERATION and ARGS.
|
2021-02-03 17:48:09 +00:00
|
|
|
|
First arg specifies the OPERATION, second arg is a list of
|
|
|
|
|
arguments to pass to the OPERATION."
|
2024-10-30 09:39:02 +00:00
|
|
|
|
(if-let* ((fn (assoc operation tramp-rclone-file-name-handler-alist)))
|
Reorganize Tramp's messages
* doc/misc/tramp.texi (Traces and Profiles): Use proper buffer
names. Add tramp-debug-command-messages.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler):
* lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler):
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler):
Set `tramp-debug-message-fnh-function'.
* lisp/net/tramp.el (tramp-file-name-handler):
* lisp/net/tramp-adb.el (tramp-adb-maybe-open-connection):
* lisp/net/tramp-crypt.el (tramp-crypt-maybe-open-connection):
* lisp/net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection):
* lisp/net/tramp-rclone.el (tramp-rclone-maybe-open-connection):
* lisp/net/tramp-sh.el (tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-maybe-open-connection):
* lisp/net/tramp-sshfs.el (tramp-sshfs-maybe-open-connection):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-maybe-open-connection):
Wrap code `with-tramp-debug-message'.
* lisp/net/tramp-message.el: New file.
* lisp/net/tramp.el (tramp-message): Require.
(tramp-verbose, tramp-debug-to-file, tramp-debug-buffer-name)
(tramp-debug-outline-regexp, tramp-debug-font-lock-keywords)
(tramp-debug-outline-level)
(tramp-debug-buffer-command-completion-p)
(tramp-setup-debug-buffer, tramp-get-debug-buffer)
(tramp-get-debug-file-name, tramp-trace-buffer-name)
(tramp-trace-functions, tramp-debug-message, tramp-message)
(tramp-backtrace, tramp-error, tramp-error-show-message-timeout)
(tramp-error-with-buffer, tramp-user-error)
(tramp-with-demoted-errors): Move to tramp-message.el.
(tramp-current-connection, tramp-file-name-user-domain)
(tramp-file-name-host-port): Add ;;;###tramp-autoload cookie.
(tramp-inhibit-progress-reporter): Move down.
(tramp-post-process-creation): Write debug message only when there
is a command.
* lisp/net/trampver.el (tramp-repository-branch)
(tramp-repository-version): Add ;;;###tramp-autoload cookie.
* test/lisp/net/tramp-tests.el (tramp--test-instrument-test-case):
Don't bind `trace-buffer'.
2023-07-29 11:11:01 +00:00
|
|
|
|
(prog1 (save-match-data (apply (cdr fn) args))
|
|
|
|
|
(setq tramp-debug-message-fnh-function (cdr fn)))
|
|
|
|
|
(prog1 (tramp-run-real-handler operation args)
|
|
|
|
|
(setq tramp-debug-message-fnh-function operation))))
|
2018-11-24 13:01:36 +00:00
|
|
|
|
|
|
|
|
|
;;;###tramp-autoload
|
* lisp/net/tramp: Rework mutual dependencies
Functionally split tramp-loaddefs.el into two parts: one part run
while loading it at the very beginning of loading tramp.el (holding plain
autoloads and declarations), and another run at the very end of loading
tramp.el (holding setup code).
This should reduce infinite-recursion problems while loading.
* lisp/net/tramp.el: Require tramp-loaddefs at beginning.
Run (new and internal) tramp--startup-hook at the end.
Remove all tramp-autoloads. Prefer tramp--with-startup over
eval-after-load.
(tramp--with-startup): New macro.
(tramp-set-syntax): Show the new value rather than the old value in the
error message.
(tramp-syntax-values): Explicitly return 'values'.
(tramp-prefix-format, tramp-prefix-regexp, tramp-method-regexp)
(tramp-postfix-method-format, tramp-postfix-method-regexp)
(tramp-prefix-ipv6-format, tramp-prefix-ipv6-regexp)
(tramp-postfix-ipv6-format, tramp-postfix-ipv6-regexp)
(tramp-postfix-host-format, tramp-postfix-host-regexp)
(tramp-remote-file-name-spec-regexp, tramp-file-name-structure)
(tramp-completion-file-name-regexp): Don't initialize in the declaration,
since it's recomputed at the end anyway.
(tramp-time-dont-know, tramp-time-doesnt-exist): Move before first use.
* lisp/net/tramp-compat.el: Don't require tramp-loaddefs any more.
(tramp-compat-tramp-syntax): Declare tramp-syntax.
* lisp/net/tramp-smb.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-ftp.el:
* lisp/net/tramp-adb.el: Wrap all autoloaded setup operations within
tramp--with-startup.
* lisp/net/tramp-sh.el: Wrap all autoloaded setup operations within
tramp--with-startup.
(tramp-display-escape-sequence-regexp)
(tramp-device-escape-sequence-regexp): Don't tramp-autoload any more.
(tramp-stat-marker): Use eval-and-compile rather than tramp-autoload.
* lisp/net/tramp-sudoedit.el: Wrap all autoloaded setup operations within
tramp--with-startup.
Require tramp-sh at compile-time to precompute some regexps based on
tramp-stat-marker.
2018-12-16 15:32:53 +00:00
|
|
|
|
(tramp--with-startup
|
|
|
|
|
(tramp-register-foreign-file-name-handler
|
|
|
|
|
#'tramp-rclone-file-name-p #'tramp-rclone-file-name-handler))
|
2018-11-24 13:01:36 +00:00
|
|
|
|
|
|
|
|
|
;;;###tramp-autoload
|
|
|
|
|
(defun tramp-rclone-parse-device-names (_ignore)
|
|
|
|
|
"Return a list of (nil host) tuples allowed to access."
|
2018-11-27 13:52:58 +00:00
|
|
|
|
(with-tramp-connection-property nil "rclone-device-names"
|
2024-05-09 08:38:37 +00:00
|
|
|
|
(tramp-compat-seq-keep
|
|
|
|
|
(lambda (line)
|
|
|
|
|
(when (string-match (rx bol (group (+ (not blank))) ":" eol) line)
|
|
|
|
|
`(nil ,(match-string 1 line))))
|
|
|
|
|
(tramp-process-lines nil tramp-rclone-program "listremotes"))))
|
2018-11-24 13:01:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; File name primitives.
|
|
|
|
|
|
|
|
|
|
(defun tramp-rclone-do-copy-or-rename-file
|
|
|
|
|
(op filename newname &optional ok-if-already-exists keep-date
|
|
|
|
|
preserve-uid-gid preserve-extended-attributes)
|
|
|
|
|
"Copy or rename a remote file.
|
|
|
|
|
OP must be `copy' or `rename' and indicates the operation to perform.
|
|
|
|
|
FILENAME specifies the file to copy or rename, NEWNAME is the name of
|
|
|
|
|
the new file (for copy) or the new name of the file (for rename).
|
|
|
|
|
OK-IF-ALREADY-EXISTS means don't barf if NEWNAME exists already.
|
|
|
|
|
KEEP-DATE means to make sure that NEWNAME has the same timestamp
|
|
|
|
|
as FILENAME. PRESERVE-UID-GID, when non-nil, instructs to keep
|
|
|
|
|
the uid and gid if both files are on the same host.
|
|
|
|
|
PRESERVE-EXTENDED-ATTRIBUTES is ignored.
|
|
|
|
|
|
|
|
|
|
This function is invoked by `tramp-rclone-handle-copy-file' and
|
|
|
|
|
`tramp-rclone-handle-rename-file'. It is an error if OP is neither
|
|
|
|
|
of `copy' and `rename'. FILENAME and NEWNAME must be absolute
|
|
|
|
|
file names."
|
2022-09-10 11:10:47 +00:00
|
|
|
|
;; FILENAME and NEWNAME are already expanded.
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(unless (memq op '(copy rename))
|
|
|
|
|
(error "Unknown operation `%s', must be `copy' or `rename'" op))
|
|
|
|
|
|
|
|
|
|
(setq filename (file-truename filename))
|
|
|
|
|
(if (file-directory-p filename)
|
|
|
|
|
(progn
|
|
|
|
|
(copy-directory filename newname keep-date t)
|
|
|
|
|
(when (eq op 'rename) (delete-directory filename 'recursive)))
|
|
|
|
|
|
|
|
|
|
(let ((t1 (tramp-tramp-file-p filename))
|
|
|
|
|
(t2 (tramp-tramp-file-p newname))
|
2023-07-01 08:19:37 +00:00
|
|
|
|
(equal-remote (tramp-equal-remote filename newname))
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(rclone-operation (if (eq op 'copy) "copyto" "moveto"))
|
|
|
|
|
(msg-operation (if (eq op 'copy) "Copying" "Renaming")))
|
|
|
|
|
|
|
|
|
|
(with-parsed-tramp-file-name (if t1 filename newname) nil
|
2022-07-24 14:02:10 +00:00
|
|
|
|
(tramp-barf-if-file-missing v filename
|
|
|
|
|
(when (and (not ok-if-already-exists) (file-exists-p newname))
|
|
|
|
|
(tramp-error v 'file-already-exists newname))
|
|
|
|
|
(when (and (file-directory-p newname)
|
|
|
|
|
(not (directory-name-p newname)))
|
|
|
|
|
(tramp-error v 'file-error "File is a directory %s" newname))
|
2023-07-01 08:19:37 +00:00
|
|
|
|
(when (file-regular-p newname)
|
|
|
|
|
(delete-file newname))
|
2022-07-24 14:02:10 +00:00
|
|
|
|
|
2023-07-01 08:19:37 +00:00
|
|
|
|
(if (or (and equal-remote
|
|
|
|
|
(tramp-get-connection-property v "direct-copy-failed"))
|
|
|
|
|
(and t1 (not (tramp-rclone-file-name-p filename)))
|
2022-07-24 14:02:10 +00:00
|
|
|
|
(and t2 (not (tramp-rclone-file-name-p newname))))
|
|
|
|
|
|
|
|
|
|
;; We cannot copy or rename directly.
|
|
|
|
|
(let ((tmpfile (tramp-compat-make-temp-file filename)))
|
|
|
|
|
(if (eq op 'copy)
|
|
|
|
|
(copy-file
|
|
|
|
|
filename tmpfile t keep-date preserve-uid-gid
|
|
|
|
|
preserve-extended-attributes)
|
|
|
|
|
(rename-file filename tmpfile t))
|
|
|
|
|
(rename-file tmpfile newname ok-if-already-exists))
|
|
|
|
|
|
|
|
|
|
;; Direct action.
|
|
|
|
|
(with-tramp-progress-reporter
|
|
|
|
|
v 0 (format "%s %s to %s" msg-operation filename newname)
|
|
|
|
|
(unless (zerop
|
|
|
|
|
(tramp-rclone-send-command
|
|
|
|
|
v rclone-operation
|
|
|
|
|
(tramp-rclone-remote-file-name filename)
|
|
|
|
|
(tramp-rclone-remote-file-name newname)))
|
2023-07-01 08:19:37 +00:00
|
|
|
|
(if (or (not equal-remote)
|
|
|
|
|
(and equal-remote
|
|
|
|
|
(tramp-get-connection-property
|
|
|
|
|
v "direct-copy-failed")))
|
|
|
|
|
(tramp-error
|
|
|
|
|
v 'file-error
|
|
|
|
|
"Error %s `%s' `%s'" msg-operation filename newname)
|
|
|
|
|
|
|
|
|
|
;; Some WebDAV server, like the one from QNAP, do
|
|
|
|
|
;; not support direct copy/move. Try a fallback.
|
|
|
|
|
(tramp-set-connection-property v "direct-copy-failed" t)
|
|
|
|
|
(tramp-rclone-do-copy-or-rename-file
|
|
|
|
|
op filename newname ok-if-already-exists keep-date
|
|
|
|
|
preserve-uid-gid preserve-extended-attributes))))
|
2022-07-24 14:02:10 +00:00
|
|
|
|
|
|
|
|
|
(when (and t1 (eq op 'rename))
|
|
|
|
|
(while (file-exists-p filename)
|
|
|
|
|
(with-parsed-tramp-file-name filename v1
|
|
|
|
|
(tramp-flush-file-properties v1 v1-localname))))
|
|
|
|
|
|
|
|
|
|
(when t2
|
|
|
|
|
(with-parsed-tramp-file-name newname v2
|
|
|
|
|
(tramp-flush-file-properties v2 v2-localname)))))))))
|
2018-11-24 13:01:36 +00:00
|
|
|
|
|
|
|
|
|
(defun tramp-rclone-handle-copy-file
|
|
|
|
|
(filename newname &optional ok-if-already-exists keep-date
|
|
|
|
|
preserve-uid-gid preserve-extended-attributes)
|
|
|
|
|
"Like `copy-file' for Tramp files."
|
2020-01-24 13:41:44 +00:00
|
|
|
|
(setq filename (expand-file-name filename)
|
|
|
|
|
newname (expand-file-name newname))
|
2018-11-24 13:01:36 +00:00
|
|
|
|
;; At least one file a Tramp file?
|
|
|
|
|
(if (or (tramp-tramp-file-p filename)
|
|
|
|
|
(tramp-tramp-file-p newname))
|
|
|
|
|
(tramp-rclone-do-copy-or-rename-file
|
|
|
|
|
'copy filename newname ok-if-already-exists keep-date
|
|
|
|
|
preserve-uid-gid preserve-extended-attributes)
|
|
|
|
|
(tramp-run-real-handler
|
2019-02-28 09:33:05 +00:00
|
|
|
|
#'copy-file
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(list filename newname ok-if-already-exists keep-date
|
|
|
|
|
preserve-uid-gid preserve-extended-attributes))))
|
|
|
|
|
|
Remove Emacs 25 compatibility from Tramp
* doc/misc/tramp.texi (Remote programs, Remote processes)
(Frequently Asked Questions): Adapt Emacs versions.
* doc/misc/trampver.texi:
* lisp/net/trampver.el: Change version to "2.6.0-pre".
* lisp/net/tramp-adb.el (top): Don't use `tramp-compat-funcall' for
connection-local functions.
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-handle-temporary-file-directory)
(tramp-compat-temporary-file-directory-function)
(tramp-compat-file-attribute-type)
(tramp-compat-file-attribute-link-number)
(tramp-compat-file-attribute-user-id)
(tramp-compat-file-attribute-group-id)
(tramp-compat-file-attribute-access-time)
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-status-change-time)
(tramp-compat-file-attribute-size)
(tramp-compat-file-attribute-modes, tramp-file-missing)
(tramp-compat-file-missing, tramp-compat-file-local-name): Remove.
(tramp-compat-file-name-quoted-p, tramp-compat-file-name-quote)
(tramp-compat-file-name-unquote)
(tramp-compat-progress-reporter-update)
(tramp-compat-file-modes, tramp-compat-set-file-modes)
(tramp-compat-set-file-times, tramp-compat-directory-files)
(tramp-compat-directory-files-and-attributes): Adapt implementation.
* lisp/net/tramp.el:
* lisp/net/tramp-adb.el:
* lisp/net/tramp-archive.el:
* lisp/net/tramp-crypt.el:
* lisp/net/tramp-fuse.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-sh.el:
* lisp/net/tramp-smb.el:
* lisp/net/tramp-sudoedit.el: Adapt callees.
* lisp/net/tramp-crypt.el (tramp-crypt-config-file-name):
Expand file name.
* lisp/net/tramp-fuse.el (tramp-fuse-handle-file-readable-p): Remove.
* lisp/net/tramp-gvfs.el (tramp-gvfs-enabled): Don't check Emacs version.
(tramp-gvfs-handler-mounted-unmounted): Use `make-tramp-file-name'.
* lisp/net/tramp-integration.el (rfn-eshadow-overlay):
Remove declaration.
(top): Don't use `tramp-compat-funcall' for connection-local functions.
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
Use `tramp-rclone-handle-file-readable-p'.
(tramp-rclone-handle-file-readable-p): New defun.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Use `tramp-handle-file-readable-p'.
* lisp/net/tramp.el (tramp-temp-name-prefix, tramp-lookup-syntax):
Adapt docstring.
(tramp-set-connection-local-variables)
(tramp-set-connection-local-variables-for-buffer): Don't use
`tramp-compat-funcall' for connection-local functions.
(tramp-file-name-for-operation): Reorder list.
(tramp-handle-make-symbolic-link): Don't handle TARGET and
OK-IF-ALREADY-EXISTS.
(tramp-read-passwd): Don't use `read-passwd' any longer.
(top): Don't check for `interrupt-process-functions'.
* test/lisp/net/tramp-archive-tests.el (tramp-archive--test-emacs26-p):
Remove.
(tramp-archive-test02-file-name-dissect): Use `make-tramp-file-name'.
(all): Replace Emacs 26 compatibility functions with their
original name.
(tramp-archive-test46-auto-load)
(tramp-archive-test46-delay-load): Rename.
* test/lisp/net/tramp-tests.el (dired-aux, seq): Require them.
(dired-compress, connection-local-criteria-alist)
(connection-local-profile-alist, async-shell-command-width):
Don't declare.
(all): Replace Emacs 26 compatibility functions with their
original name.
(tramp-test04-substitute-in-file-name)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test15-copy-directory)
(tramp-test17-insert-directory)
(tramp-test17-dired-with-wildcards, tramp-test21-file-links)
(tramp-test31-interrupt-process)
(tramp-test34-connection-local-variables)
(tramp-test34-explicit-shell-file-name)
(tramp-test40-make-nearby-temp-file)
(tramp-test41-special-characters, tramp-test42-utf8)
(tramp-test46-delay-load, tramp-test46-remote-load-path)
(tramp-test47-unload): Don't check for Emacs 26 special features.
(tramp--test-emacs26-p): Remove.
(tramp--test-emacs29-p): New defun.
(tramp-test45-dired-compress-file)
(tramp-test45-dired-compress-dir): Use it.
(tramp-test44-asynchronous-requests): Use `seq-random-elt'.
2021-11-12 17:17:32 +00:00
|
|
|
|
(defun tramp-rclone-handle-file-readable-p (filename)
|
|
|
|
|
"Like `file-readable-p' for Tramp files."
|
|
|
|
|
(with-parsed-tramp-file-name (expand-file-name filename) nil
|
|
|
|
|
(with-tramp-file-property v localname "file-readable-p"
|
|
|
|
|
(file-readable-p (tramp-fuse-local-file-name filename)))))
|
|
|
|
|
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(defun tramp-rclone-handle-file-system-info (filename)
|
|
|
|
|
"Like `file-system-info' for Tramp files."
|
|
|
|
|
(ignore-errors
|
|
|
|
|
(unless (file-directory-p filename)
|
|
|
|
|
(setq filename (file-name-directory filename)))
|
|
|
|
|
(with-parsed-tramp-file-name (expand-file-name filename) nil
|
|
|
|
|
(tramp-message v 5 "file system info: %s" localname)
|
2023-06-26 13:48:48 +00:00
|
|
|
|
(when (zerop (tramp-rclone-send-command v "about" (concat host ":")))
|
|
|
|
|
(with-current-buffer (tramp-get-connection-buffer v)
|
|
|
|
|
(let (total used free)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (not (eobp))
|
|
|
|
|
(when (looking-at (rx "Total: " (+ blank) (group (+ digit))))
|
|
|
|
|
(setq total (string-to-number (match-string 1))))
|
|
|
|
|
(when (looking-at (rx "Used: " (+ blank) (group (+ digit))))
|
|
|
|
|
(setq used (string-to-number (match-string 1))))
|
|
|
|
|
(when (looking-at (rx "Free: " (+ blank) (group (+ digit))))
|
|
|
|
|
(setq free (string-to-number (match-string 1))))
|
|
|
|
|
(forward-line))
|
|
|
|
|
(when used
|
|
|
|
|
;; The used number of bytes is not part of the result.
|
|
|
|
|
;; As side effect, we store it as file property.
|
|
|
|
|
(tramp-set-file-property v localname "used-bytes" used))
|
|
|
|
|
;; Result.
|
|
|
|
|
(when (and total free)
|
|
|
|
|
(list total free (- total free)))))))))
|
2018-11-24 13:01:36 +00:00
|
|
|
|
|
|
|
|
|
(defun tramp-rclone-handle-rename-file
|
|
|
|
|
(filename newname &optional ok-if-already-exists)
|
|
|
|
|
"Like `rename-file' for Tramp files."
|
2020-01-24 13:41:44 +00:00
|
|
|
|
(setq filename (expand-file-name filename)
|
|
|
|
|
newname (expand-file-name newname))
|
2018-11-24 13:01:36 +00:00
|
|
|
|
;; At least one file a Tramp file?
|
|
|
|
|
(if (or (tramp-tramp-file-p filename)
|
|
|
|
|
(tramp-tramp-file-p newname))
|
|
|
|
|
(tramp-rclone-do-copy-or-rename-file
|
|
|
|
|
'rename filename newname ok-if-already-exists
|
|
|
|
|
'keep-date 'preserve-uid-gid)
|
|
|
|
|
(tramp-run-real-handler
|
2019-02-28 09:33:05 +00:00
|
|
|
|
#'rename-file (list filename newname ok-if-already-exists))))
|
2018-11-24 13:01:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; File name conversions.
|
|
|
|
|
|
|
|
|
|
(defun tramp-rclone-remote-file-name (filename)
|
|
|
|
|
"Return FILENAME as used in the `rclone' command."
|
2023-01-06 12:34:33 +00:00
|
|
|
|
(setq filename (file-name-unquote (expand-file-name filename)))
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(if (tramp-rclone-file-name-p filename)
|
|
|
|
|
(with-parsed-tramp-file-name filename nil
|
2018-12-06 15:11:27 +00:00
|
|
|
|
;; As long as we call `tramp-rclone-maybe-open-connection' here,
|
|
|
|
|
;; we cache the result.
|
|
|
|
|
(with-tramp-file-property v localname "remote-file-name"
|
|
|
|
|
(tramp-rclone-maybe-open-connection v)
|
|
|
|
|
;; TODO: This shall be handled by `expand-file-name'.
|
|
|
|
|
(setq localname
|
Use `rx' in Tramp where possible
* lisp/net/tramp.el:
* lisp/net/tramp-adb.el:
* lisp/net/tramp-archive.el:
* lisp/net/tramp-cache.el:
* lisp/net/tramp-cmds.el:
* lisp/net/tramp-compat.el:
* lisp/net/tramp-crypt.el:
* lisp/net/tramp-ftp.el:
* lisp/net/tramp-fuse.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-integration.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-sh.el:
* lisp/net/tramp-smb.el:
* lisp/net/tramp-sudoedit.el: Use `rx' where possible.
* lisp/net/tramp-adb.el (tramp-adb-handle-set-file-times):
Use `eval-when-compile'.
(tramp-adb-maybe-open-connection): Use file-property for "/". Use
`eval-when-compile'.
* lisp/net/tramp-cmds.el (mm-7bit-chars): Declare.
(tramp-reporter-dump-variable): Simplify point movement.
* lisp/net/tramp-gvfs.el (tramp-dbus-function): Fix typo.
(tramp-zeroconf-parse-device-names): Use `tramp-prefix-port-format'.
* lisp/net/tramp-sh.el (tramp-open-shell, tramp-find-shell):
Use `eval-when-compile'. Improve sanity check.
* lisp/net/tramp.el (tramp-prefix-format, tramp-prefix-regexp)
(tramp-method-regexp, tramp-postfix-method-format)
(tramp-postfix-method-regexp, tramp-prefix-ipv6-format)
(tramp-prefix-ipv6-regexp, tramp-postfix-ipv6-format)
(tramp-postfix-ipv6-regexp, tramp-postfix-host-format)
(tramp-postfix-host-regexp, tramp-remote-file-name-spec-regexp)
(tramp-file-name-structure, tramp-file-name-regexp)
(tramp-completion-method-regexp)
(tramp-completion-file-name-regexp): Declare.
(tramp-set-syntax): Set also `tramp-completion-method-regexp'.
(tramp-volume-letter-regexp, tramp-completion-method-regexp-alist):
New defconsts.
(tramp-build-completion-method-regexp): New defun.
(tramp-completion-method-regexp): New defvar.
(tramp-completion-file-name-regexp-default)
(tramp-completion-file-name-regexp-simplified)
(tramp-completion-file-name-regexp-separate)
(tramp-completion-file-name-regexp-alist): Remove.
(tramp-build-completion-file-name-regexp): Rwrite.
(tramp-make-tramp-file-name): Use `tramp-archive-method'.
(tramp-handle-file-directory-p): Ignore errors.
(tramp-handle-find-backup-file-name, tramp-handle-lock-file)
(tramp-handle-make-auto-save-file-name): Use `eval-when-compile'.
* test/lisp/net/tramp-archive-tests.el:
* test/lisp/net/tramp-tests.el: Use `rx' where possible.
(tramp-test01-file-name-syntax): Adapt test.
2022-08-26 14:19:47 +00:00
|
|
|
|
(replace-regexp-in-string (rx bol ".") "" (or localname "")))
|
2021-03-08 11:05:29 +00:00
|
|
|
|
(format "%s%s" (tramp-fuse-mounted-p v) localname)))
|
2018-12-06 15:11:27 +00:00
|
|
|
|
;; It is a local file name.
|
2018-11-24 13:01:36 +00:00
|
|
|
|
filename))
|
|
|
|
|
|
|
|
|
|
(defun tramp-rclone-maybe-open-connection (vec)
|
|
|
|
|
"Maybe open a connection VEC.
|
|
|
|
|
Does not do anything if a connection is already open, but re-opens the
|
|
|
|
|
connection if a previous connection has died for some reason."
|
2019-09-12 14:38:48 +00:00
|
|
|
|
;; During completion, don't reopen a new connection.
|
|
|
|
|
(unless (tramp-connectable-p vec)
|
|
|
|
|
(throw 'non-essential 'non-essential))
|
|
|
|
|
|
Reorganize Tramp's messages
* doc/misc/tramp.texi (Traces and Profiles): Use proper buffer
names. Add tramp-debug-command-messages.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler):
* lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler):
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler):
Set `tramp-debug-message-fnh-function'.
* lisp/net/tramp.el (tramp-file-name-handler):
* lisp/net/tramp-adb.el (tramp-adb-maybe-open-connection):
* lisp/net/tramp-crypt.el (tramp-crypt-maybe-open-connection):
* lisp/net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection):
* lisp/net/tramp-rclone.el (tramp-rclone-maybe-open-connection):
* lisp/net/tramp-sh.el (tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-maybe-open-connection):
* lisp/net/tramp-sshfs.el (tramp-sshfs-maybe-open-connection):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-maybe-open-connection):
Wrap code `with-tramp-debug-message'.
* lisp/net/tramp-message.el: New file.
* lisp/net/tramp.el (tramp-message): Require.
(tramp-verbose, tramp-debug-to-file, tramp-debug-buffer-name)
(tramp-debug-outline-regexp, tramp-debug-font-lock-keywords)
(tramp-debug-outline-level)
(tramp-debug-buffer-command-completion-p)
(tramp-setup-debug-buffer, tramp-get-debug-buffer)
(tramp-get-debug-file-name, tramp-trace-buffer-name)
(tramp-trace-functions, tramp-debug-message, tramp-message)
(tramp-backtrace, tramp-error, tramp-error-show-message-timeout)
(tramp-error-with-buffer, tramp-user-error)
(tramp-with-demoted-errors): Move to tramp-message.el.
(tramp-current-connection, tramp-file-name-user-domain)
(tramp-file-name-host-port): Add ;;;###tramp-autoload cookie.
(tramp-inhibit-progress-reporter): Move down.
(tramp-post-process-creation): Write debug message only when there
is a command.
* lisp/net/trampver.el (tramp-repository-branch)
(tramp-repository-version): Add ;;;###tramp-autoload cookie.
* test/lisp/net/tramp-tests.el (tramp--test-instrument-test-case):
Don't bind `trace-buffer'.
2023-07-29 11:11:01 +00:00
|
|
|
|
(with-tramp-debug-message vec "Opening connection"
|
|
|
|
|
(let ((host (tramp-file-name-host vec)))
|
|
|
|
|
(when (rassoc `(,host) (tramp-rclone-parse-device-names nil))
|
|
|
|
|
(if (tramp-string-empty-or-nil-p host)
|
|
|
|
|
(tramp-error vec 'file-error "Storage %s not connected" host))
|
|
|
|
|
;; We need a process bound to the connection buffer.
|
|
|
|
|
;; Therefore, we create a dummy process. Maybe there is a
|
|
|
|
|
;; better solution?
|
|
|
|
|
(unless (get-buffer-process (tramp-get-connection-buffer vec))
|
|
|
|
|
(let ((p (make-network-process
|
|
|
|
|
:name (tramp-get-connection-name vec)
|
|
|
|
|
:buffer (tramp-get-connection-buffer vec)
|
|
|
|
|
:server t :host 'local :service t :noquery t)))
|
|
|
|
|
(tramp-post-process-creation p vec)
|
|
|
|
|
|
|
|
|
|
;; Set connection-local variables.
|
|
|
|
|
(tramp-set-connection-local-variables vec)))
|
|
|
|
|
|
|
|
|
|
;; Create directory.
|
|
|
|
|
(unless (file-directory-p (tramp-fuse-mount-point vec))
|
|
|
|
|
(make-directory (tramp-fuse-mount-point vec) 'parents))
|
|
|
|
|
|
|
|
|
|
;; Mount. This command does not return, so we use 0 as
|
|
|
|
|
;; DESTINATION of `tramp-call-process'.
|
|
|
|
|
(unless (tramp-fuse-mounted-p vec)
|
|
|
|
|
(apply
|
|
|
|
|
#'tramp-call-process
|
|
|
|
|
vec tramp-rclone-program nil 0 nil
|
|
|
|
|
"mount" (tramp-fuse-mount-spec vec)
|
|
|
|
|
(tramp-fuse-mount-point vec)
|
|
|
|
|
(tramp-get-method-parameter vec 'tramp-mount-args))
|
|
|
|
|
(while (not (file-exists-p (tramp-make-tramp-file-name vec 'noloc)))
|
|
|
|
|
(tramp-cleanup-connection vec 'keep-debug 'keep-password))
|
|
|
|
|
|
|
|
|
|
;; Mark it as connected.
|
|
|
|
|
(add-to-list 'tramp-fuse-mount-points (tramp-file-name-unify vec))
|
|
|
|
|
(tramp-set-connection-property
|
|
|
|
|
(tramp-get-connection-process vec) "connected" t))))
|
|
|
|
|
|
|
|
|
|
;; In `tramp-check-cached-permissions', the connection properties
|
|
|
|
|
;; "{uid,gid}-{integer,string}" are used. We set them to proper values.
|
|
|
|
|
(with-tramp-connection-property
|
|
|
|
|
vec "uid-integer" (tramp-get-local-uid 'integer))
|
|
|
|
|
(with-tramp-connection-property
|
|
|
|
|
vec "gid-integer" (tramp-get-local-gid 'integer))
|
|
|
|
|
(with-tramp-connection-property
|
|
|
|
|
vec "uid-string" (tramp-get-local-uid 'string))
|
|
|
|
|
(with-tramp-connection-property
|
|
|
|
|
vec "gid-string" (tramp-get-local-gid 'string))))
|
2018-11-24 13:01:36 +00:00
|
|
|
|
|
|
|
|
|
(defun tramp-rclone-send-command (vec &rest args)
|
Adapt Tramp docstrings according to checkdoc
* lisp/net/tramp.el (tramp-backup-directory-alist)
(tramp-echoed-echo-mark-regexp, tramp-syntax-values)
(tramp-lookup-syntax, tramp-build-prefix-format)
(tramp-build-prefix-regexp, tramp-build-method-regexp)
(tramp-build-postfix-method-format)
(tramp-build-postfix-method-regexp)
(tramp-build-prefix-ipv6-format, tramp-build-prefix-ipv6-regexp)
(tramp-build-postfix-ipv6-format)
(tramp-build-postfix-ipv6-regexp)
(tramp-build-postfix-host-format)
(tramp-build-postfix-host-regexp, tramp-unknown-id-string)
(tramp-unknown-id-integer, tramp-build-file-name-regexp)
(tramp-build-completion-file-name-regexp, tramp-chunksize)
(tramp-find-method, tramp-find-user, tramp-find-host)
(tramp-dissect-file-name, tramp-get-buffer)
(tramp-get-connection-buffer, tramp-debug-message, tramp-error)
(with-tramp-connection-property, tramp-run-real-handler)
(tramp-file-name-for-operation, tramp-file-name-handler)
(tramp-completion-file-name-handler)
(tramp-completion-handle-file-name-completion)
(tramp-completion-dissect-file-name)
(tramp-completion-dissect-file-name1)
(tramp-handle-file-name-as-directory)
(tramp-handle-file-name-directory)
(tramp-handle-file-name-nondirectory, tramp-mode-string-to-int)
(tramp-file-mode-from-int):
* lisp/net/tramp-adb.el (tramp-adb-file-name-p):
* lisp/net/tramp-archive.el (tramp-archive-run-real-handler)
(tramp-archive-file-name-handler)
(tramp-archive-dissect-file-name)
(with-parsed-tramp-archive-file-name)
(tramp-archive-gvfs-file-name, tramp-archive-handle-access-file):
* lisp/net/tramp-cmds.el (tramp-list-remote-buffers):
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-compat-funcall, tramp-compat-tramp-file-name-slots):
* lisp/net/tramp-ftp.el (tramp-ftp-file-name-handler)
(tramp-ftp-file-name-p):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-p)
(tramp-gvfs-file-name-handler)
(tramp-gvfs-stringify-dbus-message)
(tramp-gvfs-monitor-process-filter)
(tramp-gvfs-handler-mounted-unmounted):
* lisp/net/tramp-integration.el
(tramp-rfn-eshadow-update-overlay-regexp):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-p)
(tramp-rclone-file-name-handler, tramp-rclone-send-command):
* lisp/net/tramp-sh.el (tramp-sh--quoting-style-options)
(tramp-sh-gio-monitor-process-filter)
(tramp-sh-gvfs-monitor-dir-process-filter)
(tramp-sh-inotifywait-process-filter, tramp-find-executable)
(tramp-set-remote-path, tramp-open-shell, tramp-find-shell)
(tramp-send-command-and-check, tramp-shell-case-fold)
(tramp-get-remote-path):
* lisp/net/tramp-smb.el (tramp-smb-file-name-p)
(tramp-smb-file-name-handler)
(tramp-smb-do-file-attributes-with-stat)
(tramp-smb-handle-substitute-in-file-name)
(tramp-smb-get-stat-capability, tramp-smb-shell-quote-argument):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-p)
(tramp-sudoedit-file-name-handler)
(tramp-sudoedit-send-command-string):
* test/lisp/net/tramp-archive-tests.el (tramp-archive-test-all):
* test/lisp/net/tramp-tests.el (tramp--test-gvfs-p)
(tramp--test-with-proper-process-name-and-buffer)
(tramp-test-all): Adapt docstrings according to `checkdoc'.
2019-11-13 12:10:58 +00:00
|
|
|
|
"Send a command to connection VEC.
|
|
|
|
|
The command is the list of strings ARGS."
|
2018-11-24 13:01:36 +00:00
|
|
|
|
(with-current-buffer (tramp-get-connection-buffer vec)
|
|
|
|
|
(erase-buffer)
|
|
|
|
|
(let ((flags (tramp-get-method-parameter
|
|
|
|
|
vec (intern (format "tramp-%s-args" (car args))))))
|
2019-02-28 09:33:05 +00:00
|
|
|
|
(apply #'tramp-call-process
|
2018-11-24 13:01:36 +00:00
|
|
|
|
vec tramp-rclone-program nil t nil (append args flags)))))
|
|
|
|
|
|
|
|
|
|
(add-hook 'tramp-unload-hook
|
|
|
|
|
(lambda ()
|
|
|
|
|
(unload-feature 'tramp-rclone 'force)))
|
|
|
|
|
|
|
|
|
|
(provide 'tramp-rclone)
|
|
|
|
|
|
|
|
|
|
;;; tramp-rclone.el ends here
|