[
https://issues.apache.org/jira/browse/CAMEL-6254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13700132#comment-13700132
]
Barry Kelly commented on CAMEL-6254:
------------------------------------
Problem is also in git repo as at time of this comment.
Setting stepwise to false avoids the bug, as it skips the "optimization" the
code is trying to do.
> Sftp changeCurrentDirectory doesn't work for some combinations of state
> -----------------------------------------------------------------------
>
> Key: CAMEL-6254
> URL: https://issues.apache.org/jira/browse/CAMEL-6254
> Project: Camel
> Issue Type: Bug
> Components: camel-ftp
> Affects Versions: 2.10.4, 2.10.5
> Environment: Linux, OpenSSH sftp
> Reporter: Barry Kelly
>
> The changeCurrentDirectory function in SftpOperations doesn't work correctly
> for certain combinations of state. It appears as a failure to change
> directory, to some directory with the first letter missing; e.g. failed to
> chdir to 'ploads', when current directory is '/uploads' and target directory
> is '/'.
> The code can't work:
> if (getCurrentDirectory().startsWith(path)) {
> // use relative path
> String p = getCurrentDirectory().substring(path.length());
> if (p.length() == 0) {
> return;
> }
> // the first character must be '/' and hence removed
> path = UP_DIR_PATTERN.matcher(p).replaceAll("/..").substring(1);
> }
> If getCurrentDirectory() is "/uploads", and path is "/", following this logic
> through, path will end up as "ploads". This fails later.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira