corgibytes / sftp_server

A simple SFTP server for testing clients
MIT License
9 stars 7 forks source link

How to Specify the Root Path #2

Open joshhepworth opened 9 years ago

joshhepworth commented 9 years ago

When connecting in the context of a Rails app, it seems to use the Rails.root (or perhaps the bundler root) for the root. Is there a way to explicitly define a directory to use as the root?

For example, I have some mock data that I would like to be in the SFTP server when it starts up, and I've put that in /Users/Josh/name-of-rails-app/lib/sftp-root, which I would like to be the root. I'm unfortunately not very familiar with libssh and haven't be able to figure it out by reading your source or the docs for libssh.

Any help would be appreciated, or even just knowing if that's currently possible with this gem.

joshhepworth commented 9 years ago

Just figured it out. It's based on where the command to start the server is run from, so the following fixes it:

Dir.chdir(Rails.root.join("path", "to", "root")) do
  # Code from the sample server here
end
mscottford commented 9 years ago

I think this is worth implementing, instead of it being implicit. Thanks for the feedback!

joshhepworth commented 9 years ago

Also, it looks like I might've gotten excited too soon. While the above will start the server in the current directory, it's not actually setting the root. A GUI program I used to test (Transmit) still shows the full path to the directory that it defaults to.