Unfortunately, after digging through the source code for the FileConsumer, it
seems that although most of the framework is there for matching the
directories themselves, there appears to be one area preventing it from
adding the directory itself to the files list for further processing.

Taken from
https://github.com/apache/camel/blob/e7563a7611667fb9b449d8a7f8c3fa7e3a0524bd/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java:

            if (file.isDirectory()) {
                if (endpoint.isRecursive() && depth < endpoint.getMaxDepth()
&& isValidFile(gf, true, files)) {
                    // recursive scan and add the sub files and folders
                    String subDirectory = fileName + File.separator +
file.getName();
                    boolean canPollMore = pollDirectory(subDirectory,
fileList, depth);
                    if (!canPollMore) {
                        return false;
                    }
                }
            } else {
                // Windows can report false to a file on a share so regard
it always as a file (if its not a directory)
                if (depth >= endpoint.minDepth && isValidFile(gf, false,
files)) {
                    log.trace("Adding valid file: {}", file);
                    // matched file so add
                    fileList.add(gf);
                }

            }

Notice that the fileList is only added to if the file is NOT a directory. I
think if fileList.add(gf); is added to the third line above, this will solve
my problem, however it is not yet supported. I wonder if this is deliberate
behaviour or if should be raised as a bug...



--
View this message in context: 
http://camel.465427.n5.nabble.com/Polling-a-directory-for-inner-directories-tp5754812p5754831.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to