Issue with Sftp upload

Nov 6, 2010 at 2:35 PM

Hi,

I've tried to upload a file on a UNIX machine using Sftp.UploadFile(string, string).

The file has been uploaded on the target computer, there are no errors raised but when I open the file, at the end of the file, some lines are duplicated from the middle of the file.

I' m using the source from the change set 3628. Do you need some specific information to identify the problem?

Thanks

PS: thanks for the previous implementation with the error message it works great.

 

Coordinator
Nov 6, 2010 at 4:08 PM
How big is a file? Does it happens all the time or just sometimes? Does the uploaded file bigger then the source due to duplicate lines? Is it ASCII or binary file?

Thanks,
Oleg

Sent from my iPhone

On Nov 6, 2010, at 10:37, "Peuj"<notifications@codeplex.com> wrote:

From: Peuj

Hi,

I've tried to upload a file on a UNIX machine using Sftp.UploadFile(string, string).

The file has been uploaded on the target computer, there are no errors raised but when I open the file, at the end of the file, some lines are duplicated from the middle of the file.

I' m using the source from the change set 3628. Do you need some specific information to identify the problem?

Thanks

PS: thanks for the previous implementation with the error message it works great.

Read the full discussion online.

To add a post to this discussion, reply to this email (sshnet@discussions.codeplex.com)

To start a new discussion for this project, email sshnet@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Nov 6, 2010 at 6:04 PM
Edited Nov 6, 2010 at 6:05 PM

Hi,

I've just tried with the same file. It happens all the time with always the same duplicated lines.

I didn't check if the file is bigger in size. It should as there are 4 or 5 lines more.

As it's a shell file I'll say that it's ASCII (?).

I'll try to make more tests this week end if I have time.

 

Nov 8, 2010 at 11:45 AM

Hi,

I've looked at the code and I've the found the problem:

In the method UploadFile(Stream source, string destination) the buffer sent to RemoteWrite doesn't correspond to the buffer read.

I've modified the code this way (in bold the important change):

int bytesRead = 0;
while ((bytesRead = source.Read(buffer, 0, buffer.Length)) > 0)
{
    var finalBuffer = buffer.Take(bytesRead);
    this.RemoteWrite(handle, offset, finalBuffer.GetSshString());
    offset += (ulong)buffer.Length;
}

 

Thanks

 

 

 

 

Coordinator
Nov 8, 2010 at 12:56 PM

Hi Peuj,

 

Thanks for reporting this problem. I just incorporated the fix into latest code base.

 

Thanks,

Oleg