-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
request server: add WithStartDirectory option #498
Conversation
Hi @puellanivis thanks for your review, I'll fix the PR based on your comments. I know that removing the RealPathLister is a breaking change, but it does not work for real use cases. It only works if you have a client that initially requests the start directory and then sends absolute paths based on the response. I think it is very unlikely that anyone actually uses this interface. If someone is really using it, they should fix their code by migrating to the new server option. |
We can just label the interface as deprecated, and say that implementing it won’t actually do anything. The same as we have |
Thank you! |
I am not finding an example of how to use this with a real file system. I am a bit confused by the InMemHandler(). I would have prefered the WithStartDirectory() to have been a method applied to NewServer() which would have done the same thing as starting 'sftp-server -d [startDirectory]'. Is there an example of how this can be called and work with a real file system? |
The reason for
|
Alternative approach to support a start directory.
I tested #497 and it works fine but I don't like that pkg/sftp clean the path and I have to clean the raw path again in my code.
This approach seems cleaner and the
RealPathFileLister
is useless if we go this way, we can remove this interface.The only drawback is that NewRequest now requires an already cleaned path. Prior to this patch the path passed to NewRequest was converted to an absolute UNIX path using
/
as base. I'll try to fix this compatibility issue later