You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by David Latorre <dv...@gmail.com> on 2012/06/18 18:28:07 UTC

Re: How to rename on complete

Hello,

 I would say sebb's answer is the easiest way to go.

 If this is not a solution for you,   there are several possible solutions:

- You can implement your own version of "STOR/STOU" commands and  invoke
the rename there. Done this, it works but I prefer sebb's solution.

- You can develop a "Filesystem" implementation which locks files. Never
tried this, but should work.

- Don't lock or rename files, just change the 'client' which is reading the
incomplete files.  We integrate different channels, not only FTP,  so we
always do this.  Whenever we find a new file we store the size and
timestamp and we wait for some time to check if the file has been changed.
When we detect that the file isn't being changed anymore, we process it.


Would that be enough for you ?



2012/5/28 sebb <se...@gmail.com>

> On 24 May 2012 01:44, Charles W. Stanton <cw...@gmail.com> wrote:
> > I just downloaded the Mina source code and am looking through it.  What
> I'd
> > like is a way to have the Mina sftp server accept and save a file to one
> > name, like originalName_tmp, then change the name to originalName after
> the
> > transfer is complete.  That way I can have an external process watching
> the
> > directory know for sure when the transfer is done.  Right now I'm
> grabbing
> > partial files, even if I try to get a read lock.  (Stupid Java...)
> >
> > Any quick thoughts?  Is there an easy way to plug in to the Mina
> > architecture?  Or override a class?  Or...
>
> Use the client to ask the server to rename the file once it has been
> uploaded?
>
> Note that the code will need to allow for the case where the rename fails.
>