Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Simon Newsgroups: comp.lang.php Subject: Re: Prevent unlink(...) warning Date: Thu, 17 Nov 2011 19:21:52 +0200 Lines: 50 Message-ID: <9iku5gFi18U1@mid.individual.net> References: <9ikm3eFih4U1@mid.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net nVxNfP1/VMWfnSH4EFT/2gF6tG46OLPe10onmqqqJJAbqbkIXc Cancel-Lock: sha1:qskja/Zj5rchSD9YO22lF7NGVt8= User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: Xref: x330-a1.tempe.blueboxinc.net comp.lang.php:3819 On 2011/11/17 05:18 PM, The Natural Philosopher wrote: > Simon wrote: >> Hi, >> >> I am having some race condition issues on my server when trying to >> delete a file. >> > > what makes you think its a race condition? A guess really, If I do: ... if (file_exists($filename)) { and followed by ... @unlink($filename); } And that gives me a unlink(/home/xxx/public_html/temp/yyy.zz) [function.unlink]: No such file or directory The something between file_exists(...) and @unlink(...) must have removed the file. Either that or one of the two functions is not working as expected. > > Why do you care about the stat cache? > As per the doc, http://php.net/manual/en/function.clearstatcache.php, to make sure that file_exists($filename) does return a cached value. >> >> How can I prevent the warning? >> > Why prevent it at all? > > As long as the file is not there when you are finished - why not just > unlink it anyway? > Because the warnings fill my logs and I aim for no warnings at all. Simon