EldoS | Feel safer!

Software components for data protection, secure storage and transfer

SFTP Server OnFindFirst fires twice

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
#24006
Posted: 03/10/2013 22:22:35
by Brett Beattie (Standard support level)
Joined: 03/08/2011
Posts: 25

Hi, I am using the SFTP Server (TElSFTPSSHSubsystemHandler) and have noticed the OnFindFirst event is fired twice when navigating to a directory. I can't see why this would happen. Is there a reason for it?

I would prefer it if I can stop this behaviour or determine if it is a second fire? (As the directory list process can potentially be expensive in this instance).

I have seen this behaviour using your DEMO server and client applications, as well as using an alternative client (CoreFTP), and a project of my own.
#24011
Posted: 03/11/2013 04:13:17
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

Hi.
This is the 'feature' of our SFTP client demo - it sends two directory-related requests - first just open/closes the directory handle to ensure that directory exists and readable, and the second reads the directory contents.
For instance, WinSCP client uses only one call.
#24012
Posted: 03/11/2013 04:16:18
by Vsevolod Ievgiienko (EldoS Corp.)

Thank you for contacting us.

If talking about our demo client, it sends "open directory" command twice:

1) The 1st is sent by OpenDirectory() method called from Form1.cs:frmMain.ChangeDir(). Its called to check if we can access a directory.
2) The 2nd is sent by ListDirectory() method called from Form1.cs:frmMain.Refresh(). A files list is retrieved there.

Most likely third party client act the same way.

TElSFTPSSHSubsystemHandler.OnFindFirst itself should not be an *expensive* operation. Our SFTP server demo includes non-optimal OnFindFirst handler implementation (because its simple and easy to understand). You should consider rewriting it to minimize its resource requirements.
#24023
Posted: 03/11/2013 18:00:45
by Brett Beattie (Standard support level)
Joined: 03/08/2011
Posts: 25

Thanks guys. Based on your responses I will implement a type of directory listing cache with a short expiry (250ms) to catch this type of scenario. If the cache has not expired I wont reload the directoy contents.

(I am using your SFTP server to provide access to a sort of dynamic virtual folder structure. The directory listing comes from a web service call, which in turn can load the contents from a file system, xml file, database, another web service or anything really. I am using the OnFindFirst event to trigger the call to the web service that loads the directory contents.)

Reply

Statistics

Topic viewed 407 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!