diff --git a/src/Renci.SshNet/Renci.SshNet.csproj b/src/Renci.SshNet/Renci.SshNet.csproj index 9b7af1590..44e4e3172 100644 --- a/src/Renci.SshNet/Renci.SshNet.csproj +++ b/src/Renci.SshNet/Renci.SshNet.csproj @@ -2,19 +2,19 @@ Renci.SshNet - SSH.NET - SSH.NET + Microsoft.PowerPlatform.Connector.SSH.NET + Microsoft.PowerPlatform.Connector.SSH.NET net462;netstandard2.0;net8.0;net9.0;net10.0 true - SSH.NET - SSH.NET + Microsoft.PowerPlatform.Connector.SSH.NET + Microsoft.PowerPlatform.Connector.SSH.NET SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism. Copyright © Renci 2010-$([System.DateTime]::UtcNow.Year) MIT - Renci + Microsoft SS-NET-icon-h500.png README.md ssh; scp; sftp diff --git a/src/Renci.SshNet/SftpClient.cs b/src/Renci.SshNet/SftpClient.cs index 947139f84..5701ad45b 100644 --- a/src/Renci.SshNet/SftpClient.cs +++ b/src/Renci.SshNet/SftpClient.cs @@ -2322,11 +2322,21 @@ private List InternalListDirectory(string path, SftpListDirectoryAsyn asyncResult?.Update(result.Count); - // Call callback to report number of files read + // NOTE(apseth): Execute callback and return result if operation cancellation requested by the callback. if (listCallback is not null) { - // Execute callback on different thread + // Execute callback on different thread ThreadAbstraction.ExecuteThread(() => listCallback(result.Count)); + try + { + listCallback(result.Count); + } + catch (OperationCanceledException) + { + DiagnosticAbstraction.Log("The callback operation was cancelled, returning the result."); + _sftpSession.RequestClose(handle); + return result; + } } files = _sftpSession.RequestReadDir(handle);