File locking mechanism is probably a very good idea. It just has to
interact with events from FTP though.


On Wed, Oct 30, 2013 at 7:11 AM, [email protected] <
[email protected]> wrote:

> why don't you implement a file locking mechanism ? it's the better and
> simplest solution
>
> ----Messaggio originale----
> Da: [email protected]
> Data: 22-ott-2013 15.29
> A: <[email protected]>
> Ogg: Re: locking files while being downloaded
>
> The afterCommand will execute at the end rather. My issue is while a user
> is downloading the file, I do not want another connection to download it
> for  a second time.
>
> At the end of the download we intend to remove the successfully downloaded
> files so that will take care of a second download anyway.
>
> You are right though, an Ftplet should handle this.
>
> Thank you,
>
>
> On Tue, Oct 22, 2013 at 7:41 AM, Dave Roberts <
> [email protected]> wrote:
>
> > On 21/10/2013 21:15, Gentian Hila wrote:
> > > Is there any way to make sure that when one file is downloaded from the
> > > user, a second connection from the same user won't be able to download
> it
> > > again?
> >
> > An Ftplet implementation should be able to handle this.
> >
> > You could physically move/remove the file in the afterCommand
> > method, but that would mean that only 1 user ever downloads the
> > file.  The advantage is that you've nothing further to monitor.
> >
> > Alternatively you could monitor the downloads per user with some map
> > field, as you suggest.  You can add to this when afterCommand is
> > passed a 226 (as per your other query from yesterday).  Then in the
> > beforeCommand method, you check if the file already exists in the
> > map for that user.  Or to lock the file, add the reference in the
> > beforeCommand, and remove it on failure in the afterCommand.
> >
> > The user information can be obtained from the FtpSession passed in
> > to both methods.
> >
> > Obviously you'll need some means of expiring entries from the Map
> > otherwise it will grow continually.
> >
> > Anything more elaborate (like filtering out the downloaded file
> > names from any file listing), you'll need to provide your own
> > FileSystemFactory etc. implementation or extend the existing Native one.
> >
>
>
>

Reply via email to