On 3 March 2011 19:59, Ashley M. Kirchner <ash...@pcraft.com> wrote:
>
>
>                Is there a clean or reliable way of checking to see if a
> file is still being written to before doing anything with it?
>
>
>
>                Here's the scenario: we have a Samba share that we can copy
> files to (from within Windows or Macs).  The server picks up the file and
> does some processing of said file.  At the moment this is all a manual
> process: we copy a file into the Samba share, wait for that to finish then
> go to a web page (on the server) and tell it to process the file that was
> just copied into the Samba share.  I'm trying to see if there is a way to
> automate this where a file, or multiple files, get copied into the share and
> the server picks them up and process automatically without needing any
> interaction.
>
>
>
>                Can PHP detect this, or should I look into some delayed
> process of checking the file's modified time stamp versus current time and
> not touch the file till a certain threshold has been reached (say 30 seconds
> difference?).
>
>
>
>                Ideas, suggestions, comments .
>
>

I have a similar issue with files coming from a scanner connected to
our network over a VPN. There end is only 10mb and the scans are
significant.

The one thing I found that I can rely on is the date the file was last modified.

I have a process to copy the files if the saved file is more than 10
minutes old. Locking didn't happen (the scanning didn't create the
file locked in any way).

It was quite easy to amend the file whilst it was being written to by
the scanner. Nothing I could do about that.

The 10 minute delay on reading the file was fine for us.


-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to