RE: Check for open file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2011-03-03 at 15:29 -0500, Steve Staples wrote:

> 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
> 
> 


As far as I was aware, if you're in the middle of writing to a file and
another script was attempting to write to it, the OS would prevent that
as you had an open lock on it.

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux