You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2021/06/23 05:20:00 UTC
[jira] [Updated] (CAMEL-16745) camel-ftp - excludeExt/includeExt
not getting the right filename extension
[ https://issues.apache.org/jira/browse/CAMEL-16745?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen updated CAMEL-16745:
--------------------------------
Summary: camel-ftp - excludeExt/includeExt not getting the right filename extension (was: excludeExt/includeExt not getting the right filename extension)
> camel-ftp - excludeExt/includeExt not getting the right filename extension
> --------------------------------------------------------------------------
>
> Key: CAMEL-16745
> URL: https://issues.apache.org/jira/browse/CAMEL-16745
> Project: Camel
> Issue Type: Improvement
> Components: camel-ftp
> Affects Versions: 3.10.0
> Reporter: Huang
> Priority: Major
> Labels: excludeExt, includeExt
> Fix For: 3.11.0
>
> Original Estimate: 12h
> Remaining Estimate: 12h
>
> When I use includeExt=zip to filter files in FTP component, it not worked as I expected.
> If I have a file named aaa.bbb.ccc.zip, it will get "bbb.ccc.zip" as the extension, which I expected was "zip".
> From the code of GenericFileConsumer<T>.isMatched in camel-file I found that
>
> {code:java}
> if (includeExt != null) {
> String ext = FileUtil.onlyExt(file.getFileName());
> boolean any = false;
> for (String include : includeExt) {
> any |= include.equalsIgnoreCase(ext);
> }
> if (!any) {
> return false;
> }
> }
> {code}
> Class FileUtil from camel-util:
> {code:java}
> public static String onlyExt(String name) {
> return onlyExt(name, false);
> }
> public static String onlyExt(String name, boolean singleMode) {
> if (name == null) {
> return null;
> }
> name = stripPath(name); // extension is the first dot, as a file may have double extension such as .tar.gz
> // if single ext mode, then only return last extension
> int pos = singleMode ? name.lastIndexOf('.') : name.indexOf('.');
> if (pos != -1) {
> return name.substring(pos + 1);
> }
> return null;
> }
> {code}
>
> May be we should change "String ext = FileUtil.onlyExt(file.getFileName());" to "String ext = FileUtil.onlyExt(file.getFileName(), true);" or add an "singleMode" parameter for compatibility。
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)