PutFiles not thorwing Exception even path in sFTP not exists

Advertisement

jzu
Joined:
Posts:
11
Location:
Hong Kong

PutFiles not thorwing Exception even path in sFTP not exists

As subject, I tried to upload a file to a sftp folder which actually does not exists.:cry:
Expected the method returns me exception telling me the path in sftp does not exists after call Check(), but it does not, it just works like success.
I've checked the transferResult also no failures in the collection.

Checked 5.1.7 and 5.2.3 Beta also has this problem.

Environment:
Windows 7 Professional
Visual Studio 2010
Assembly: 5.1.7 and 5.2.3 beta


Please follow up as we are going to use this nice assembly for development.


DebugLog:


. 2013-08-21 00:13:45.178 Using SFTP protocol.
. 2013-08-21 00:13:45.178 Doing startup conversation with host.
> 2013-08-21 00:13:45.178 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2013-08-21 00:13:45.207 Type: SSH_FXP_VERSION, Size: 5, Number: -1
. 2013-08-21 00:13:45.207 SFTP version 3 negotiated.
. 2013-08-21 00:13:45.207 We believe the server has signed timestamps bug
. 2013-08-21 00:13:45.207 We will use UTF-8 strings for status messages only
. 2013-08-21 00:13:45.207 Getting current directory name.
. 2013-08-21 00:13:45.207 Getting real path for '.'
> 2013-08-21 00:13:45.207 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
< 2013-08-21 00:13:45.227 Type: SSH_FXP_NAME, Size: 23, Number: 16
. 2013-08-21 00:13:45.227 Real path is '/'
. 2013-08-21 00:13:45.227 Startup conversation with host finished.
< 2013-08-21 00:13:45.229 Script: Active session: [1] xxxx@xxx.xxx.xxx.xxx
> 2013-08-21 00:13:45.262 Script: put -nopermissions -preservetime -transfer="binary" -- "D:\xxxx\testing\dummy1.htm" "/a/"
. 2013-08-21 00:13:45.262 Copying 1 files/directories to remote directory "/a/"
. 2013-08-21 00:13:45.262 PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: S (102400); CalcS: No; Mask:
. 2013-08-21 00:13:45.263 TM: B; ClAr: No; CPS: 0; NewerOnly: No; InclM:
. 2013-08-21 00:13:45.263 AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2013-08-21 00:13:45.263 File: "D:\xxxx\testing\dummy1.htm"
. 2013-08-21 00:13:45.263 Copying "D:\xxxx\testing\dummy1.htm" to remote directory started.
. 2013-08-21 00:13:45.263 Binary transfer mode selected.
. 2013-08-21 00:13:45.263 Opening remote file.
> 2013-08-21 00:13:45.263 Type: SSH_FXP_OPEN, Size: 38, Number: 259
< 2013-08-21 00:13:45.286 Type: SSH_FXP_HANDLE, Size: 24, Number: 259
> 2013-08-21 00:13:45.286 Type: SSH_FXP_WRITE, Size: 4132, Number: 774
. 2013-08-21 00:13:45.287 11 skipped SSH_FXP_WRITE, SSH_FXP_READ, SSH_FXP_DATA and SSH_FXP_STATUS packets.
> 2013-08-21 00:13:45.287 Type: SSH_FXP_CLOSE, Size: 24, Number: 3844
> 2013-08-21 00:13:45.287 Type: SSH_FXP_SETSTAT, Size: 34, Number: 521
< 2013-08-21 00:13:45.316 Type: SSH_FXP_STATUS, Size: 31, Number: 774
< 2013-08-21 00:13:45.518 Type: SSH_FXP_STATUS, Size: 31, Number: 1030
< 2013-08-21 00:13:45.518 Type: SSH_FXP_STATUS, Size: 31, Number: 1286
< 2013-08-21 00:13:45.518 Type: SSH_FXP_STATUS, Size: 31, Number: 1542
< 2013-08-21 00:13:45.518 Type: SSH_FXP_STATUS, Size: 31, Number: 1798
< 2013-08-21 00:13:45.518 Type: SSH_FXP_STATUS, Size: 31, Number: 2054
< 2013-08-21 00:13:45.518 Type: SSH_FXP_STATUS, Size: 31, Number: 2310
< 2013-08-21 00:13:45.518 Type: SSH_FXP_STATUS, Size: 31, Number: 2566
< 2013-08-21 00:13:45.518 Type: SSH_FXP_STATUS, Size: 31, Number: 2822
< 2013-08-21 00:13:45.518 Type: SSH_FXP_STATUS, Size: 31, Number: 3078
< 2013-08-21 00:13:45.518 Type: SSH_FXP_STATUS, Size: 31, Number: 3334
< 2013-08-21 00:13:45.518 Type: SSH_FXP_STATUS, Size: 31, Number: 3590
< 2013-08-21 00:13:45.518 Type: SSH_FXP_STATUS, Size: 17, Number: 3844
< 2013-08-21 00:13:45.518 Status code: 0
. 2013-08-21 00:13:45.518 Preserving timestamp [2013-08-17T03:14:30.000Z]
< 2013-08-21 00:13:45.518 Type: SSH_FXP_STATUS, Size: 48, Number: 521
< 2013-08-21 00:13:45.518 Status code: 0
> 2013-08-21 00:13:45.690 Script: exit
. 2013-08-21 00:13:45.690 Script: Exit code: 0
. 2013-08-21 00:13:45.690 Closing connection.
. 2013-08-21 00:13:45.690 Sending special code: 12
. 2013-08-21 00:13:45.691 Sent EOF message


where folder "/a/" doesn't exist in the sftp.


Thanks so much. :P
Last edited by jzu on 2013-08-20 17:20; edited 1 time in total

Reply with quote

Advertisement

JasonRkr
Joined:
Posts:
13
Location:
Sunny Southern California

jzu,

Can you post your code for review? It's difficult to help determine issues without being able to see the code.

Regards,

Jason

Reply with quote

jzu
Joined:
Posts:
11
Location:
Hong Kong

JasonRkr wrote:

jzu,

Can you post your code for review? It's difficult to help determine issues without being able to see the code.

Regards,

Jason

Hi Jason,

Thanks for reply, below is the code

public void UploadFile(string files, string dFTPPath, bool deleteSourceFile = false)
        {
            try
            {
                var result = GetSession().PutFiles(files, dFTPPath, deleteSourceFile);
                result.Check();
            }
            catch (Exception)
            {
                throw;
            }
        }

To test: just simply upload a file to a folder that doesn't exist in sftp

Jackson

Reply with quote

JasonRkr
Joined:
Posts:
13
Location:
Sunny Southern California

jzu,

At the risk of sounding dumb, doesn't your use of the "void" keyword mean it's not going to return anything to whatever is calling it?

Jason

Reply with quote

jzu
Joined:
Posts:
11
Location:
Hong Kong

JasonRkr wrote:

jzu,

At the risk of sounding dumb, doesn't your use of the "void" keyword mean it's not going to return anything to whatever is calling it?

Jason

Jason,

You're right. This function is not intended to return a result, it will just do nothing if success, or throw exception if any.
I've done the same thing for the GetFiles method, it will throw exception when path doesn't exist, but however PutFiles doesn't.

Jackson

Reply with quote

Advertisement

JasonRkr
Joined:
Posts:
13
Location:
Sunny Southern California

jzu,

Sorry, I'm having trouble duplicating your code. Would it be possible to get the entire app, without private stuff, of course?

Thanks,

Jason

Reply with quote

JasonRkr
Joined:
Posts:
13
Location:
Sunny Southern California

jzu,

Are you using the 5.1.7 version? I installed that one today and am seeing an issue similar to yours when trying to download a file that doesn't exist. It should have thrown an exception, but didn't.

Jason

Reply with quote

jzu
Joined:
Posts:
11
Location:
Hong Kong

Jason,

As mentioned at the top, I've tried both 5.1.7 and 5.2.3 beta, they both has such issue.
The GetFiles works fine for me, no such issue.

Have you tried the same thing in your own library? Did you got the exception if path doesn't exist?

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: PutFiles not thorwing Exception even path in sFTP not exists

jzu wrote:

As subject, I tried to upload a file to a sftp folder which actually does not exists.:cry:
Expected the method returns me exception telling me the path in sftp does not exists after call Check(), but it does not, it just works like success.
I've checked the transferResult also no failures in the collection.
There's no error in log. Meaning your server did not indicate any error back to WinSCP. Hence WinSCP considered the upload successful.
But just to be sure, can you post a Debug 1-level log file (you can simply try the same upload from GUI to collect such log easily).

Reply with quote

jzu
Joined:
Posts:
11
Location:
Hong Kong

Re: PutFiles not thorwing Exception even path in sFTP not exists

You're right, I tried the GUI and also no error message is returned.
I'll contact the sftp admin to see what's happened to the settings, thanks for your information.
Btw, do you know any related options in the Linux server to configure to enable the Put file error notification??

1-level log:

. 2013-08-21 23:43:22.136 Session upkeep
. 2013-08-21 23:43:22.635 Session upkeep
. 2013-08-21 23:43:23.149 Session upkeep
. 2013-08-21 23:43:23.650 Session upkeep
. 2013-08-21 23:43:24.164 Session upkeep
. 2013-08-21 23:43:24.664 Session upkeep
. 2013-08-21 23:43:25.178 Session upkeep
. 2013-08-21 23:43:25.678 Session upkeep
. 2013-08-21 23:43:26.192 Session upkeep
. 2013-08-21 23:43:26.691 Session upkeep
. 2013-08-21 23:43:27.209 Session upkeep
. 2013-08-21 23:43:27.447 Copying 1 files/directories to remote directory "/bbb/"
. 2013-08-21 23:43:27.449 PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: S (102400); CalcS: Yes; Mask:
. 2013-08-21 23:43:27.449 TM: B; ClAr: No; CPS: 0; NewerOnly: No; InclM:
. 2013-08-21 23:43:27.449 AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2013-08-21 23:43:27.449 File: "C:\Users\lai_jack\Desktop\dummy1.htm"
. 2013-08-21 23:43:27.460 Copying "C:\Users\lai_jack\Desktop\dummy1.htm" to remote directory started.
. 2013-08-21 23:43:27.463 Binary transfer mode selected.
. 2013-08-21 23:43:27.466 Opening remote file.
> 2013-08-21 23:43:27.466 Type: SSH_FXP_OPEN, Size: 40, Number: 13827
. 2013-08-21 23:43:27.466 Sent 44 bytes
. 2013-08-21 23:43:27.466 There are 0 bytes remaining in the send buffer
. 2013-08-21 23:43:27.466 Read 4 bytes (17 pending)
. 2013-08-21 23:43:27.466 Read 17 bytes (0 pending)
< 2013-08-21 23:43:27.466 Type: SSH_FXP_STATUS, Size: 17, Number: 13572
. 2013-08-21 23:43:27.466 Discarding reserved response
. 2013-08-21 23:43:27.466 Waiting for another 4 bytes
. 2013-08-21 23:43:27.898 Detected network event
. 2013-08-21 23:43:27.927 Session upkeep
. 2013-08-21 23:43:27.933 Received 30 bytes (0)
. 2013-08-21 23:43:27.933 Read 4 bytes (26 pending)
. 2013-08-21 23:43:27.933 Read 26 bytes (0 pending)
< 2013-08-21 23:43:27.933 Type: SSH_FXP_HANDLE, Size: 26, Number: 13827
. 2013-08-21 23:43:27.933 Write request offset: 0, len: 4096
> 2013-08-21 23:43:27.933 Type: SSH_FXP_WRITE, Size: 4134, Number: 14342
. 2013-08-21 23:43:27.933 Sent 4138 bytes
. 2013-08-21 23:43:27.933 There are 0 bytes remaining in the send buffer
. 2013-08-21 23:43:27.961 Write request offset: 4096, len: 4096
> 2013-08-21 23:43:27.961 Type: SSH_FXP_WRITE, Size: 4134, Number: 14598
. 2013-08-21 23:43:27.961 Sent 4138 bytes
. 2013-08-21 23:43:27.961 There are 0 bytes remaining in the send buffer
. 2013-08-21 23:43:27.962 Write request offset: 8192, len: 16342
> 2013-08-21 23:43:27.962 Type: SSH_FXP_WRITE, Size: 16380, Number: 14854
. 2013-08-21 23:43:27.962 Sent 16384 bytes
. 2013-08-21 23:43:27.962 There are 0 bytes remaining in the send buffer
. 2013-08-21 23:43:27.962 Write request offset: 24534, len: 16342
> 2013-08-21 23:43:27.962 Type: SSH_FXP_WRITE, Size: 16380, Number: 15110
. 2013-08-21 23:43:27.963 Sent 16384 bytes
. 2013-08-21 23:43:27.963 There are 0 bytes remaining in the send buffer
. 2013-08-21 23:43:28.013 Write request offset: 40876, len: 7926
> 2013-08-21 23:43:28.013 Type: SSH_FXP_WRITE, Size: 7964, Number: 15366
. 2013-08-21 23:43:28.014 Sent 7968 bytes
. 2013-08-21 23:43:28.014 There are 0 bytes remaining in the send buffer
> 2013-08-21 23:43:28.014 Type: SSH_FXP_CLOSE, Size: 26, Number: 15620
. 2013-08-21 23:43:28.014 Sent 30 bytes
. 2013-08-21 23:43:28.014 There are 0 bytes remaining in the send buffer
> 2013-08-21 23:43:28.014 Type: SSH_FXP_SETSTAT, Size: 36, Number: 14089
. 2013-08-21 23:43:28.014 Sent 40 bytes
. 2013-08-21 23:43:28.014 There are 0 bytes remaining in the send buffer
. 2013-08-21 23:43:28.014 Waiting for another 4 bytes
. 2013-08-21 23:43:28.054 Detected network event
. 2013-08-21 23:43:28.054 Received 35 bytes (0)
. 2013-08-21 23:43:28.054 Read 4 bytes (31 pending)
. 2013-08-21 23:43:28.054 Read 31 bytes (0 pending)
< 2013-08-21 23:43:28.054 Type: SSH_FXP_STATUS, Size: 31, Number: 14342
. 2013-08-21 23:43:28.054 Waiting for another 4 bytes
. 2013-08-21 23:43:28.618 Detected network event
. 2013-08-21 23:43:28.707 Session upkeep
. 2013-08-21 23:43:28.716 Received 213 bytes (0)
. 2013-08-21 23:43:28.716 Read 4 bytes (209 pending)
. 2013-08-21 23:43:28.716 Read 31 bytes (178 pending)
< 2013-08-21 23:43:28.716 Type: SSH_FXP_STATUS, Size: 31, Number: 14598
. 2013-08-21 23:43:28.716 Read 4 bytes (174 pending)
. 2013-08-21 23:43:28.716 Read 31 bytes (143 pending)
< 2013-08-21 23:43:28.716 Type: SSH_FXP_STATUS, Size: 31, Number: 14854
. 2013-08-21 23:43:28.716 Read 4 bytes (139 pending)
. 2013-08-21 23:43:28.716 Read 31 bytes (108 pending)
< 2013-08-21 23:43:28.716 Type: SSH_FXP_STATUS, Size: 31, Number: 15110
. 2013-08-21 23:43:28.716 Read 4 bytes (104 pending)
. 2013-08-21 23:43:28.716 Read 31 bytes (73 pending)
< 2013-08-21 23:43:28.716 Type: SSH_FXP_STATUS, Size: 31, Number: 15366
. 2013-08-21 23:43:28.716 Read 4 bytes (69 pending)
. 2013-08-21 23:43:28.716 Read 17 bytes (52 pending)
< 2013-08-21 23:43:28.716 Type: SSH_FXP_STATUS, Size: 17, Number: 15620
< 2013-08-21 23:43:28.716 Status code: 0
. 2013-08-21 23:43:28.716 Preserving timestamp [2013-08-17T03:13:57.000Z]
. 2013-08-21 23:43:28.716 Read 4 bytes (48 pending)
. 2013-08-21 23:43:28.716 Read 48 bytes (0 pending)
< 2013-08-21 23:43:28.716 Type: SSH_FXP_STATUS, Size: 48, Number: 14089
< 2013-08-21 23:43:28.716 Status code: 0
. 2013-08-21 23:43:28.717 Cached directory not reloaded.
. 2013-08-21 23:43:28.717 Listing directory "/".
> 2013-08-21 23:43:28.717 Type: SSH_FXP_OPENDIR, Size: 10, Number: 15883
. 2013-08-21 23:43:28.717 Sent 14 bytes
. 2013-08-21 23:43:28.717 There are 0 bytes remaining in the send buffer
. 2013-08-21 23:43:28.717 Waiting for another 4 bytes
. 2013-08-21 23:43:28.793 Detected network event
. 2013-08-21 23:43:28.793 Received 16 bytes (0)
. 2013-08-21 23:43:28.793 Read 4 bytes (12 pending)
. 2013-08-21 23:43:28.793 Read 12 bytes (0 pending)
< 2013-08-21 23:43:28.793 Type: SSH_FXP_HANDLE, Size: 12, Number: 15883
> 2013-08-21 23:43:28.793 Type: SSH_FXP_READDIR, Size: 12, Number: 16140
. 2013-08-21 23:43:28.793 Sent 16 bytes
. 2013-08-21 23:43:28.793 There are 0 bytes remaining in the send buffer
. 2013-08-21 23:43:28.793 Waiting for another 4 bytes
. 2013-08-21 23:43:28.872 Detected network event
. 2013-08-21 23:43:28.872 Received 152 bytes (0)
. 2013-08-21 23:43:28.872 Read 4 bytes (148 pending)
. 2013-08-21 23:43:28.872 Read 148 bytes (0 pending)
< 2013-08-21 23:43:28.872 Type: SSH_FXP_NAME, Size: 148, Number: 16140
> 2013-08-21 23:43:28.872 Type: SSH_FXP_READDIR, Size: 12, Number: 16396
. 2013-08-21 23:43:28.872 Sent 16 bytes
. 2013-08-21 23:43:28.872 There are 0 bytes remaining in the send buffer
. 2013-08-21 23:43:28.872 Read file 'xxxx.pgp' from listing
. 2013-08-21 23:43:28.902 Waiting for another 4 bytes
. 2013-08-21 23:43:28.970 Detected network event
. 2013-08-21 23:43:29.354 Session upkeep
. 2013-08-21 23:43:29.368 Received 32 bytes (0)
. 2013-08-21 23:43:29.368 Read 4 bytes (28 pending)
. 2013-08-21 23:43:29.368 Read 28 bytes (0 pending)
< 2013-08-21 23:43:29.368 Type: SSH_FXP_STATUS, Size: 28, Number: 16396
< 2013-08-21 23:43:29.368 Status code: 1
> 2013-08-21 23:43:29.368 Type: SSH_FXP_CLOSE, Size: 12, Number: 16644
. 2013-08-21 23:43:29.368 Sent 16 bytes
. 2013-08-21 23:43:29.368 There are 0 bytes remaining in the send buffer
. 2013-08-21 23:43:29.387 xxxx.pgp;-;7935010;2013-08-21T10:27:43.000Z;"root" [0];"root" [0];rw-r--r--;0
. 2013-08-21 23:43:29.430 Session upkeep
. 2013-08-21 23:43:29.430 Detected network event
. 2013-08-21 23:43:29.430 Received 21 bytes (0)
. 2013-08-21 23:43:29.733 Session upkeep
. 2013-08-21 23:43:30.248 Session upkeep
. 2013-08-21 23:43:30.747 Session upkeep
. 2013-08-21 23:43:31.262 Session upkeep
. 2013-08-21 23:43:31.761 Session upkeep
. 2013-08-21 23:43:32.276 Session upkeep
. 2013-08-21 23:43:32.775 Session upkeep
. 2013-08-21 23:43:33.290 Session upkeep
. 2013-08-21 23:43:33.806 Session upkeep
. 2013-08-21 23:43:34.305 Session upkeep
. 2013-08-21 23:43:34.820 Session upkeep
. 2013-08-21 23:43:35.320 Session upkeep
. 2013-08-21 23:43:35.834 Session upkeep
. 2013-08-21 23:43:36.333 Session upkeep
. 2013-08-21 23:43:36.848 Session upkeep
. 2013-08-21 23:43:37.348 Session upkeep
. 2013-08-21 23:43:37.862 Session upkeep
. 2013-08-21 23:43:38.362 Session upkeep
. 2013-08-21 23:43:38.875 Session upkeep
. 2013-08-21 23:43:39.375 Session upkeep
. 2013-08-21 23:43:39.889 Session upkeep
. 2013-08-21 23:43:40.389 Session upkeep
. 2013-08-21 23:43:40.903 Session upkeep
. 2013-08-21 23:43:41.404 Session upkeep
. 2013-08-21 23:43:41.917 Session upkeep
. 2013-08-21 23:43:42.569 Closing connection.
. 2013-08-21 23:43:42.569 Sending special code: 12
. 2013-08-21 23:43:42.569 Sent EOF message

Reply with quote

jzu

I've just googled for how to determine whether a file has been completed uploaded to the sftp.
It seems in sftp protocol there's no way to determine whether a upload process is success or not, am I correct?

Reply with quote

Advertisement

jzu
Joined:
Posts:
11
Location:
Hong Kong

JasonRkr wrote:

I wonder if my download is producing the same "non-error" result?

Jason

Jason,

Same here, I think it's the same issue.
I'm afraid we might need to handle it manually :x (e.g. verify the file/path exist before download/upload)

This is my first time dealing with sftp operation, can't believe the sftp protocol doesn't provide those basic acknowledgement.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

jzu wrote:

It seems in sftp protocol there's no way to determine whether a upload process is success or not, am I correct?
That's a nonsense. Of course there is.

Your server just fails to report the error back. So it's implementation-specific bug, not a problem of SFTP protocol as such.

Reply with quote

jzu
Joined:
Posts:
11
Location:
Hong Kong

martin wrote:

jzu wrote:

It seems in sftp protocol there's no way to determine whether a upload process is success or not, am I correct?
That's a nonsense. Of course there is.

Your server just fails to report the error back. So it's implementation-specific bug, not a problem of SFTP protocol as such.

Yes, we've just reported this issue to the sftp server's vendor, they seems tend to ask users to implement the verification in client side instead of server side.

I've also checked the sftp protocol specification, it really has the relative code 2 : no such file.

Thanks for your information!

Reply with quote

Advertisement

You can post new topics in this forum