RE: Check for open file

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

 



> -----Original Message-----
> From: Ashley Sheridan [mailto:ash@xxxxxxxxxxxxxxxxxxxx]
> Sent: Thursday, March 03, 2011 2:03 PM
> To: sstaples@xxxxxxxx
> Cc: php-general@xxxxxxxxxxxxx
> Subject: RE:  Check for open file
> 
> 
> 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
> 

	And as it turned out, that was not the case.  I started copying a
200MiB file from my desktop machine onto the Samba share.  While that was
copying, I got onto the server and tried to copy the file to /tmp and it
happily did that for me without any indication that it was still being
written to (which is was by the way.)  So, that's not a good way of dealing
with this.

	I think I'm going to have to go with a time delay function here ...


--

There are potential problems using timing delays, and networking compounds
them. It might be more robust to use some simple method outside of php to
indicate a file is busy being copied, like using a reserved extension for
the copy and then renaming to the proper filename after the copy is
complete, or copying to a temp directory and then moving the file to the
destination directory once copied (renames and moves take milliseconds).
Assuming you're able to automate the copy process.

Cheers
Arno



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



[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