Browse Source

Added ExistsAsync and GetAsync to ISftpClient (#1628)

Co-authored-by: Martin Solarik <martin.solarik@rws.com>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
Martin 6 tháng trước cách đây
mục cha
commit
1cc527e205
1 tập tin đã thay đổi với 31 bổ sung0 xóa
  1. 31 0
      src/Renci.SshNet/ISftpClient.cs

+ 31 - 0
src/Renci.SshNet/ISftpClient.cs

@@ -630,6 +630,22 @@ namespace Renci.SshNet
         /// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
         bool Exists(string path);
 
+        /// <summary>
+        /// Checks whether file or directory exists.
+        /// </summary>
+        /// <param name="path">The path.</param>
+        /// <param name="cancellationToken">The <see cref="CancellationToken"/> to observe.</param>
+        /// <returns>
+        /// A <see cref="Task{T}"/> that represents the exists operation.
+        /// The task result contains <see langword="true"/> if directory or file exists; otherwise <see langword="false"/>.
+        /// </returns>
+        /// <exception cref="ArgumentException"><paramref name="path"/> is <see langword="null"/> or contains only whitespace characters.</exception>
+        /// <exception cref="SshConnectionException">Client is not connected.</exception>
+        /// <exception cref="SftpPermissionDeniedException">Permission to perform the operation was denied by the remote host. <para>-or-</para> A SSH command was denied by the server.</exception>
+        /// <exception cref="SshException">A SSH error where <see cref="Exception.Message"/> is the message from the remote host.</exception>
+        /// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
+        Task<bool> ExistsAsync(string path, CancellationToken cancellationToken = default);
+
         /// <summary>
         /// Gets reference to remote file or directory.
         /// </summary>
@@ -643,6 +659,21 @@ namespace Renci.SshNet
         /// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
         ISftpFile Get(string path);
 
+        /// <summary>
+        /// Gets reference to remote file or directory.
+        /// </summary>
+        /// <param name="path">The path.</param>
+        /// <param name="cancellationToken">The <see cref="CancellationToken"/> to observe.</param>
+        /// <returns>
+        /// A <see cref="Task{ISftpFile}"/> that represents the get operation.
+        /// The task result contains the reference to <see cref="ISftpFile"/> file object.
+        /// </returns>
+        /// <exception cref="SshConnectionException">Client is not connected.</exception>
+        /// <exception cref="SftpPathNotFoundException"><paramref name="path"/> was not found on the remote host.</exception>
+        /// <exception cref="ArgumentNullException"><paramref name="path" /> is <see langword="null"/>.</exception>
+        /// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
+        Task<ISftpFile> GetAsync(string path, CancellationToken cancellationToken);
+
         /// <summary>
         /// Gets the <see cref="SftpFileAttributes"/> of the file on the path.
         /// </summary>