Skip to content

Commit 1cc527e

Browse files
MaartyMartin SolarikRob-Hague
authored
Added ExistsAsync and GetAsync to ISftpClient (#1628)
Co-authored-by: Martin Solarik <[email protected]> Co-authored-by: Rob Hague <[email protected]>
1 parent 58eaeec commit 1cc527e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/Renci.SshNet/ISftpClient.cs

+31
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,22 @@ public interface ISftpClient : IBaseClient
630630
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
631631
bool Exists(string path);
632632

633+
/// <summary>
634+
/// Checks whether file or directory exists.
635+
/// </summary>
636+
/// <param name="path">The path.</param>
637+
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to observe.</param>
638+
/// <returns>
639+
/// A <see cref="Task{T}"/> that represents the exists operation.
640+
/// The task result contains <see langword="true"/> if directory or file exists; otherwise <see langword="false"/>.
641+
/// </returns>
642+
/// <exception cref="ArgumentException"><paramref name="path"/> is <see langword="null"/> or contains only whitespace characters.</exception>
643+
/// <exception cref="SshConnectionException">Client is not connected.</exception>
644+
/// <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>
645+
/// <exception cref="SshException">A SSH error where <see cref="Exception.Message"/> is the message from the remote host.</exception>
646+
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
647+
Task<bool> ExistsAsync(string path, CancellationToken cancellationToken = default);
648+
633649
/// <summary>
634650
/// Gets reference to remote file or directory.
635651
/// </summary>
@@ -643,6 +659,21 @@ public interface ISftpClient : IBaseClient
643659
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
644660
ISftpFile Get(string path);
645661

662+
/// <summary>
663+
/// Gets reference to remote file or directory.
664+
/// </summary>
665+
/// <param name="path">The path.</param>
666+
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to observe.</param>
667+
/// <returns>
668+
/// A <see cref="Task{ISftpFile}"/> that represents the get operation.
669+
/// The task result contains the reference to <see cref="ISftpFile"/> file object.
670+
/// </returns>
671+
/// <exception cref="SshConnectionException">Client is not connected.</exception>
672+
/// <exception cref="SftpPathNotFoundException"><paramref name="path"/> was not found on the remote host.</exception>
673+
/// <exception cref="ArgumentNullException"><paramref name="path" /> is <see langword="null"/>.</exception>
674+
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
675+
Task<ISftpFile> GetAsync(string path, CancellationToken cancellationToken);
676+
646677
/// <summary>
647678
/// Gets the <see cref="SftpFileAttributes"/> of the file on the path.
648679
/// </summary>

0 commit comments

Comments
 (0)