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 2013/03/13 16:40:13 UTC

[jira] [Commented] (CAMEL-5558) Add fileExist option to write file with a new name in case file already exists

    [ https://issues.apache.org/jira/browse/CAMEL-5558?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13601251#comment-13601251 ] 

Claus Ibsen commented on CAMEL-5558:
------------------------------------

Yeah this is not an easy ticket to implement if we want to go all the way and let Camel "figure out" what the last filename with a sequence number is, and compute the next "free" name to use for renaming the existing file.

1)
I guess maybe something like adding a new attribute on file endpoint to allow to plugin a custom code to deal with the move existing file.

{code}
public interface MoveExistingFileStrategy {

   boolean moveExistingFile(GenericFileEndpoint endpoint, GenericFileOperations operations, String fileName) throws Exception;

}
{code}

Then return true if the file was moved succesfully, or false if something failed, but you do not have an exception, eg the File API in JDK returns true|false.


Then people can configure a custom strategy to do whatever they want.
And we can have a default implementation that is the current code.

2)
To support figure out free name. Then we may need to allow people to configure an option for the name pattern. I wonder if a regular expression is too complicated? Or maybe we invent our own token etc. Though lets look at this later. First step would be IMHO to have an interface where people can plugin custom strategy and be in control with java code what to do.


                
> Add fileExist option to write file with a new name in case file already exists
> ------------------------------------------------------------------------------
>
>                 Key: CAMEL-5558
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5558
>             Project: Camel
>          Issue Type: New Feature
>          Components: camel-core, camel-ftp
>    Affects Versions: 2.10.0
>            Reporter: Claus Ibsen
>             Fix For: Future
>
>
> See nabble
> http://camel.465427.n5.nabble.com/Camel-FTP-component-Append-a-sequence-number-if-the-filename-already-exists-tp5718469.html
> We should allow to configure fileExists=RenameAndRetry option, which allows you to rename the file and retry writing the file again, in case there already exists a file. 
> The trick is to find a optimal solution if  you append a sequence number to a file. And when there is a lot of files. You kinda want to know what is the highest filename, (some way of listing and sorting). 
> Maybe a way to get a list of existing files based on a file name pattern, and a sort configuration. Then people can check in the list, to find a free sequence number to use etc.

--
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