Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: Problem with uploading to Unix

$
0
0
At start I connected from outside a loop. But later I changed as it is now. I hoped that this will be solve the problem.

Now I have found problem and have solved it.

namespace Renci.SshNet
{
/// <summary>
/// Implementation of the SSH File Transfer Protocol (SFTP) over SSH.
/// </summary>
public partial class SftpClient : BaseClient
{
.
.
private void InternalUploadFile(Stream input, string path, Flags flags, SftpUploadAsyncResult asyncResult, Action<ulong> uploadCallback)
{
.
.
                {
                    expectedResponses++;
                }

                offset += (uint)bytesRead;

                bytesRead = input.Read(buffer, 0, buffer.Length);
            }
            else if (expectedResponses > 0)
            {
                //  Wait for expectedResponses to change
                lock (expectedResponsesLock)
                {
                    Monitor.Wait(expectedResponsesLock);
                }
            }
        } while (bytesRead > 0 || expectedResponses > 0);

        this._sftpSession.RequestClose(handle);
Problem occurs when network write\read speed is faster than disk write\read speed. Then the value of expectedResponses becomes equals to 0, and the file isn’t being uploaded completely.
I added new condition in method InternalUploadFile bytesRead > 0 ||

I waiting patch with this correction...

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>