One Star

tFileDelete dosn't handle failures/errors despite fail on error

Dear Readers,
In our Talend Job there is a tFileDelete component that cleans the content of a directory.
However we need handle the case when at least one file could not be deleted.
When the job executes all files but not the locked ones are deleted. These circumstance
should trigger the mechanism "fail on error" but it is not. The link to "on subjob error"
is not taken by the flow.
Kind regards,
Hilderich
4 REPLIES
One Star

Re: tFileDelete dosn't handle failures/errors despite fail on error

Do you get failure message in your component though it continues running? You can add a tAssert and a tAssertCatcher to check for this condition and connect it to a tDie to force a kill.
Seventeen Stars

Re: tFileDelete dosn't handle failures/errors despite fail on error

The file delete component is a bit strange designed!
After delete the given file the success can only be seen by this check:
"File deleted.".equals((String) globalMap.get("tFileDelete_1_CURRENT_STATUS"))

This boolean expression can be used in the if trigger.
For me this component is very bad designed. Why they do not have added a usable return value like DELETE_OK or let the component die if it does not work.
Actually if have not seen any difference in the code for fail-on-error. Probably a bug.
One Star

Re: tFileDelete dosn't handle failures/errors despite fail on error

Hello All,
We have solved it by Apache's commons-io in particular with
org.apache.commons.io.FileUtils.cleanDirectory enclosed in tJava.
Kind regards,
Hilderich
Seventeen Stars

Re: tFileDelete dosn't handle failures/errors despite fail on error

Also a good solution.