title: How to handle file server race conditions?
body: <p>I am developing an application that polls a folder on a network file server (cifs) for new files on a scheduled cron job every 1 minute.</p>
  
  <p>When it sees a new file, it copies it to the local file system temporarily while it then does various things with the file before then deleting it from both the local and network file systems.</p>
  
  <p>I have concerns about the possibility of encountering a race condition where my app polls the network folder at the same time somebody is adding a file to the network folder. The files are incredibly small (1kb) and so it should be incredibly rare that a file would still be copying when I poll the folder but it could happen.</p>
  
  <p>My question, is this a legitimate concern and if so how should I handle it?</p>