RE: [PHP] Check for open file

From: Date: Thu, 03 Mar 2011 20:29:40 +0000
Subject: RE: [PHP] Check for open file
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-311645@lists.php.net to get a copy of this message
On Thu, 2011-03-03 at 13:23 -0700, Ashley M. Kirchner wrote: > > Write the file with a temporary name and extension. Once the file is > closed, > > change the name to the pattern your server is looking for. Once you finish > > processing it, either change the name again, or move it to a different > > directory. Don't reuse the same file name, but add a numeric value which > > increases every time you create it. Keep a log of which files have been > > processed and any errors each one produced. > > > > Bob McConnell > > I can't require nor expect those copying the files into the share folder to > do this. No, they will simply be grabbing a set of image files from one > network share and drag them into this Samba share, as is. I'm not worried > with what happens when PHP picks it up (name changes, moving to a diff > folder, etc., etc.) I'm only concerned with the first step ... picking up > the file only *after* it's done copying. > > I can run PHP as a timed crontask, but I need to figure out a safe way for > it to either grab a file or leave it alone because it's not done yet. > > If i recall correctly, with FTP, the file is copied into the directory, but it is not "ready" for use... I have an application that reads the contents of a FTP directory, looking for files there... i've never had any issues where it only got a part of the file (that i know of anyways)... maybe the samba does the same thing? how large are these files (or how large would the largest file typically be) ? would it be worth looking at the "time" of the file, and waiting until that file is at least (say) 5 mintues old, then do something with it? if it only takes < 1 minute to put these files on teh share, then maybe you can reduce that time... Just thinking of alternatives... Steve

« previous php.general (#311645) next »