sshnet / sshnet/SSH.NET

SftpPermissionDeniedException on Download when File Transfer in Progress

Open
#977 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
4.4k
Forks
993
Avg merge
9d 21h
Merged PRs (30d)
1

Description

When attempting to download a file that is being written to on the source SFTP file server, I'm getting a SftpPermissionDeniedException. We trap for the error and retry the download after a 15 s pause. However, even after the file has been closed on the SFTP server the same exception occurs in code when downloading the file. It seems like the status of the file isn't updated or an exception isn't getting cleared in the SSH.NET code on subsequent download attempts.

SftpClient.DownloadFile(path, stream, callback)

The only way I've gotten this to work is to call Disconnect on the SftpClient and then Connect before attempting the download again.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the reported SftpClient.DownloadFile(path, stream, callback) entry point and reproduce a download while the remote file is being written, then retry after it closes. Trace how SftpPermissionDeniedException is handled across the retry and compare behavior with reconnecting the SftpClient. Done means a subsequent download succeeds without disconnecting and reconnecting.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.