1
votes

I have multiple FTP clients that will periodically look for new files on the FTP server. Now, if one of the client fetches a file for further processing, I want to move it to some other directory (say processed directory). Now the problem is of concurrency, how can we manage such that no two clients process the same file at the same time. One file should only be processed by only one client.

I can't think of how to handle this. Is there any tool that can be used in this case or should I write a piece of code on server side that will notify me of new files that arrive?

Thanks in advance.

1

1 Answers

1
votes

Move/rename the file first. That's an atomic operation that only one client can succeed with.

The client that succeeds, can then download the file from the new location/name.