camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bela <bv...@overturecorp.com>
Subject SftpProducer bug
Date Thu, 24 Jul 2008 21:06:57 GMT

Hi,

First let me say it's been a huge fun working with Camel! Keep up the good
work!

I have just built 1.5 from the trunk and it seems there's a bug in the
SftpProducer. I know this is not the way to report it, but for now I'm
swamped ... I promise I'll submit patches later. 

The problem is that the mkdir in the buildDirectory throws an exception when
the folder exists and it's not caught. With the current code you can only
send files to the "." (i.e. without specifying a folder).

Here is my humble change:

    protected static boolean buildDirectory(ChannelSftp sftpClient, String
dirName)
        throws IOException, SftpException {

        boolean atLeastOneSuccess = false;
        final StringBuilder sb = new StringBuilder(dirName.length());
        final String[] dirs = dirName.split("\\/");
        for (String dir : dirs) {
            sb.append(dir).append('/');
            String directory = sb.toString();

            if (LOG.isDebugEnabled()) {
                LOG.debug("Trying to build directory: " + directory);
            }
            
            try {
            	sftpClient.mkdir(directory);
                atLeastOneSuccess = true;
            }
            catch ( SftpException e ) {
            	// Nothing. Keep trying ..
            }
        }

        return atLeastOneSuccess;
    }

Thanks,
Bela
-- 
View this message in context: http://www.nabble.com/SftpProducer-bug-tp18640519s22882p18640519.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message