Skip to content
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

'/' is getting removed from directory path #83

Open
Prashant2603 opened this issue Dec 19, 2023 · 3 comments
Open

'/' is getting removed from directory path #83

Prashant2603 opened this issue Dec 19, 2023 · 3 comments

Comments

@Prashant2603
Copy link

For one of our use case where we are trying to connect to a sftp server we can see some weird behavior. In this particular case SFTP server allows cd command only with a '/' at end

  1. cd dirA/dirB/ - works
  2. cd dirA/dirB - does not work
    When we try calling sftpClient.cd("dirA/dirB/") it attempts to call cd dirA/dirB and fails.
    We tried to look into your code and it seems like '/' is removed intentionally.
    Can someone explain what is the reason for that and can we have some workaround to cd/list with '/' at the end
@Prashant2603
Copy link
Author

Prashant2603 commented Dec 21, 2023

@ludup @brett-smith @dandalf Could someone help me here?
Everywhere in code I see
// Remove trailing forward slash
if (absolutePath.endsWith("/")) {
absolutePath = absolutePath.substring(0,
absolutePath.length() - 1);
}

@ludup
Copy link
Contributor

ludup commented Feb 20, 2024

How many servers are affected by this? This is a long-standing behaviour I've not had reports about before, and this code goes back to previous generations. The furthest I can go back to is the initial commit of Maverick Legacy to private git in 2015, which still appears to do this. If I'd had a problem supporting commercial customers since that commit, there would already be a switch there.

You could propose a change to implement a configuration switch. Look at AdaptiveConfiguration, While it's not used much at the moment in Synergy, the plan is to move all configurations over to using it to match the legacy API flexibility.

@ludup
Copy link
Contributor

ludup commented Apr 3, 2024

With the 3.1.2-SNAPSHOT, you can -Dmaverick.disableSlashRemoval=true to remove the path processing.

As stated before, this code has existed for a long time and in all the years I've supported the various APIs it has not come up as a problem before. Its inclusion would suggest my former self had good reason for doing it.

You can now disable it system-wide with this system property switch. Please let us know if you encounter any problems with this switch enabled.

In a future release (3.2), it will be possible to configure this per connection through the planned extension of the Adaptive configuration file. However, if you need this before you could always modify the SftpClient to have a boolean option set on individual instances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants