`remote-file-name-access-timeout' being 0 is equal to nil
* doc/lispref/files.texi (Testing Accessibility): Clarify the value of remote-file-name-access-timeout. * etc/NEWS: Clarify the value of remote-file-name-access-timeout. * lisp/files.el (remote-file-name-access-timeout): Adapt docstring. * lisp/net//tramp.el (with-tramp-timeout): Ensure, that the timeout is a positive number, or nil. (tramp-handle-access-file): Simplify code.
This commit is contained in:
parent
e37b96432b
commit
2dc7798449
4 changed files with 38 additions and 35 deletions
|
@ -974,10 +974,11 @@ If you can read @var{filename} this function returns @code{nil};
|
|||
otherwise it signals an error
|
||||
using @var{string} as the error message text.
|
||||
|
||||
If the user option @code{remote-file-name-access-timeout} is a number,
|
||||
the function signals an error when it doesn't finish after that time
|
||||
(in seconds). This applies only to remote files, and only when there
|
||||
is no additional time spent while reading passwords or alike.
|
||||
If the user option @code{remote-file-name-access-timeout} is a
|
||||
positive number, the function signals an error when it doesn't finish
|
||||
after that time (in seconds). This applies only to remote files, and
|
||||
only when there is no additional time spent while reading passwords or
|
||||
alike.
|
||||
@end defun
|
||||
|
||||
@defun file-ownership-preserved-p filename &optional group
|
||||
|
|
6
etc/NEWS
6
etc/NEWS
|
@ -68,7 +68,7 @@ remote buffers. The default is nil.
|
|||
|
||||
+++
|
||||
** New user option 'remote-file-name-access-timeout'.
|
||||
When a natural number, this option limits the call of 'access-file'
|
||||
When a positive number, this option limits the call of 'access-file'
|
||||
for remote files to this number of seconds. Default is nil.
|
||||
|
||||
+++
|
||||
|
@ -469,9 +469,9 @@ desktop restoration to continue.
|
|||
|
||||
+++
|
||||
*** Checking recent remote files can now time out.
|
||||
Similarly to buffer restoration by "desktop", 'recentf-mode' checking
|
||||
Similarly to buffer restoration by Desktop, 'recentf-mode' checking
|
||||
of the accessibility of remote files can now time out if
|
||||
`remote-file-name-access-timeout' is set to a positive number.
|
||||
'remote-file-name-access-timeout' is set to a positive number.
|
||||
|
||||
|
||||
* New Modes and Packages in Emacs 30.1
|
||||
|
|
|
@ -1332,7 +1332,7 @@ consecutive checks. For example:
|
|||
"Timeout (in seconds) for `access-file'.
|
||||
This timeout limits the time to check, whether a remote file is
|
||||
accessible. `access-file' returns an error after that time. If
|
||||
the value is nil, no timeout is used.
|
||||
the value is 0 or nil, no timeout is used.
|
||||
|
||||
This applies only when there isn't time spent for other actions,
|
||||
like reading passwords."
|
||||
|
|
|
@ -2439,7 +2439,9 @@ without a visible progress reporter."
|
|||
(declare (indent 1) (debug ((form body) body)))
|
||||
(let ((seconds (car list))
|
||||
(timeout-forms (cdr list)))
|
||||
`(if-let (((natnump ,seconds)))
|
||||
;; If non-nil, `seconds' must be a positive number.
|
||||
`(if-let (((natnump ,seconds))
|
||||
((not (zerop timeout))))
|
||||
(with-timeout (,seconds ,@timeout-forms) ,@body)
|
||||
,@body)))
|
||||
|
||||
|
@ -3985,34 +3987,34 @@ Let-bind it when necessary.")
|
|||
(defun tramp-handle-access-file (filename string)
|
||||
"Like `access-file' for Tramp files."
|
||||
(let ((timeout
|
||||
(with-connection-local-variables
|
||||
;; This variable exists since Emacs 30.1.
|
||||
(bound-and-true-p remote-file-name-access-timeout)))
|
||||
;; This variable exists since Emacs 30.1.
|
||||
(bound-and-true-p remote-file-name-access-timeout))
|
||||
(v (tramp-dissect-file-name
|
||||
(if (file-name-absolute-p filename) filename default-directory)))
|
||||
;; We rely on timers, so don't suspend them.
|
||||
(tramp-dont-suspend-timers t))
|
||||
(with-parsed-tramp-file-name filename v
|
||||
(with-tramp-timeout
|
||||
(timeout
|
||||
(unless (when-let ((p (tramp-get-connection-process v)))
|
||||
(and (process-live-p p)
|
||||
(tramp-get-connection-property p "connected")))
|
||||
(tramp-cleanup-connection v 'keep-debug 'keep-password))
|
||||
(tramp-error
|
||||
v 'file-error
|
||||
(format
|
||||
"%s: Timeout %s second(s) accessing %s" string timeout filename)))
|
||||
(setq filename (file-truename filename))
|
||||
(if (file-exists-p filename)
|
||||
(unless
|
||||
(funcall
|
||||
(if (file-directory-p filename)
|
||||
#'file-accessible-directory-p #'file-readable-p)
|
||||
filename)
|
||||
(tramp-compat-permission-denied
|
||||
v (format "%s: Permission denied, %s" string filename)))
|
||||
(tramp-error
|
||||
v 'file-missing
|
||||
(format "%s: No such file or directory, %s" string filename)))))))
|
||||
(with-tramp-timeout
|
||||
(timeout
|
||||
(unless (when-let ((p (tramp-get-connection-process v)))
|
||||
(and (process-live-p p)
|
||||
(tramp-get-connection-property p "connected")))
|
||||
(tramp-cleanup-connection v 'keep-debug 'keep-password))
|
||||
(tramp-error
|
||||
v 'file-error
|
||||
(format
|
||||
"%s: Timeout %s second(s) accessing %s" string timeout filename)))
|
||||
(setq filename (file-truename filename))
|
||||
(if (file-exists-p filename)
|
||||
(unless
|
||||
(funcall
|
||||
(if (file-directory-p filename)
|
||||
#'file-accessible-directory-p #'file-readable-p)
|
||||
filename)
|
||||
(tramp-compat-permission-denied
|
||||
v (format "%s: Permission denied, %s" string filename)))
|
||||
(tramp-error
|
||||
v 'file-missing
|
||||
(format "%s: No such file or directory, %s" string filename))))))
|
||||
|
||||
(defun tramp-handle-add-name-to-file
|
||||
(filename newname &optional ok-if-already-exists)
|
||||
|
|
Loading…
Add table
Reference in a new issue