This is a classic problem with (s)ftp - fetching partial files.
There are two common solutions...
- Write the file with a different name, then rename it.
- Add a special file (e.g.
foo.done
when foo.zip
is complete).
Spring Integration (on the writing side) uses 1) (writes the file with foo.zip.writing
and renames to foo.zip
). This is the simplest mechanism because it's easy to filter .writing
files - Spring Integration does this automatically.
2) is a little more difficult because you need to write a custom FileListFilter
to ignore foo.zip
if foo.done
is not present.
The underlying (S)FTP protocols have no way to prevent fetching partial files without using a mechanism like these.
EDIT:
If you have no control over the sender you could write a custom filter
(FileListFilter
) that will only fetch a file if it hasn't changed since some time.
This is not a Spring Integration issue it's a problem that has to be solved for any application using (S)FTP. Spring Integration provides one solution, and all the hooks you need to solve it for your situation.